mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-06 13:28:32 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
34 lines
809 B
C#
34 lines
809 B
C#
using Microsoft.CodeAnalysis;
|
|
using Microsoft.CodeAnalysis.CSharp;
|
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
|
using Sandbox.Generator;
|
|
using System.Collections.Concurrent;
|
|
using System.Runtime.CompilerServices;
|
|
|
|
namespace Sandbox;
|
|
|
|
partial class Compiler
|
|
{
|
|
private void RunBlacklistWalker( CSharpCompilation compiler, CompilerOutput output )
|
|
{
|
|
if ( !compiler.SyntaxTrees.Any() )
|
|
{
|
|
return;
|
|
}
|
|
|
|
ConcurrentBag<Diagnostic> diagnostics = new();
|
|
|
|
var result = System.Threading.Tasks.Parallel.ForEach( compiler.SyntaxTrees, tree =>
|
|
{
|
|
var semanticModel = compiler.GetSemanticModel( tree );
|
|
|
|
var walker = new BlacklistCodeWalker( semanticModel );
|
|
walker.Visit( tree.GetRoot() );
|
|
|
|
walker.Diagnostics.ForEach( diagnostics.Add );
|
|
} );
|
|
|
|
output.Diagnostics.AddRange( diagnostics );
|
|
}
|
|
}
|