Files
sbox-public/engine/Sandbox.CodeUpgrader/Helpers/Fixer.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

44 lines
969 B
C#

using System;
namespace Sandbox.CodeUpgrader;
/// <summary>
/// Wraps CodeFixProvider to make it less of a pain in the ass
/// </summary>
public abstract partial class Fixer : CodeFixProvider
{
public virtual Task RunTests( IFixerTest tester ) => Task.CompletedTask;
public sealed override ImmutableArray<string> FixableDiagnosticIds => ImmutableArray.Create( Target.Rule.Id );
public sealed override FixAllProvider GetFixAllProvider() => WellKnownFixAllProviders.BatchFixer;
Analyzer _analyzer;
public Analyzer Target
{
get
{
return _analyzer ??= (Analyzer)Activator.CreateInstance( Analyzer );
}
}
public abstract Type Analyzer { get; }
}
/// <summary>
/// Wraps CodeFixProvider to make it less of a pain in the ass
/// </summary>
public abstract partial class Fixer<T> : Fixer where T : Analyzer
{
public override Type Analyzer => typeof( T );
}
public interface IFixerTest
{
public Task Test( string oldcode, string fixedcode );
}