Files
sbox-public/engine/Sandbox.Compiling/Compiler/Compiler.Blacklist.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

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 );
}
}