mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-03 20:08:30 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
27 lines
1023 B
C#
27 lines
1023 B
C#
using Microsoft.CodeAnalysis;
|
|
using Microsoft.CodeAnalysis.CSharp.Testing;
|
|
using Microsoft.CodeAnalysis.Diagnostics;
|
|
using Microsoft.CodeAnalysis.Testing;
|
|
namespace Sandbox.CodeUpgrader;
|
|
|
|
public class AnalyzerTest<T> : IAnalyzerTest where T : DiagnosticAnalyzer, new()
|
|
{
|
|
/// <summary>
|
|
/// This code should trigger the diagnostic.
|
|
/// </summary>
|
|
public async Task TestWithMarkup( string code )
|
|
{
|
|
var test = new CSharpAnalyzerTest<T, Microsoft.CodeAnalysis.Testing.DefaultVerifier>
|
|
{
|
|
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();
|
|
}
|
|
}
|