using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Testing; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Testing; namespace Sandbox.CodeUpgrader; public class AnalyzerTest : IAnalyzerTest where T : DiagnosticAnalyzer, new() { /// /// This code should trigger the diagnostic. /// public async Task TestWithMarkup( string code ) { var test = new CSharpAnalyzerTest { ReferenceAssemblies = ReferenceAssemblies.NetStandard.NetStandard20, TestCode = code, }; test.TestState.AdditionalReferences.Add( MetadataReference.CreateFromFile( typeof( Sandbox.Internal.GlobalGameNamespace ).Assembly.Location ) ); test.TestState.AdditionalReferences.Add( MetadataReference.CreateFromFile( typeof( Sandbox.ConCmdAttribute ).Assembly.Location ) ); test.TestState.AdditionalReferences.Add( MetadataReference.CreateFromFile( typeof( NetFlags ).Assembly.Location ) ); await test.RunAsync(); } }