Skip to content

Commit 496293f

Browse files
committed
Add verification mode
1 parent 4943a32 commit 496293f

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

ServerCodeExciser/ServerCodeExciser.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ public sealed class Settings : CommandSettings
5353
[Description("Processes everything, but does not write any output to disk.")]
5454
public bool IsDryRun { get; init; }
5555

56+
[CommandOption("-v|--verify")]
57+
[Description("Verify that all analized code does not require modifications to excise server scopes.")]
58+
public bool Verify { get; init; }
59+
5660
[CommandArgument(0, "[INPUT]")]
5761
[Description("The input folder to excise.")]
5862
public string InputPath { get; init; } = string.Empty;
@@ -81,7 +85,8 @@ public override int Execute([NotNull] CommandContext context, [NotNull] Settings
8185
parameters.ExciseAllFunctionsRegexString = settings.ExciseAllFunctionsRegexString ?? string.Empty;
8286
parameters.FullExcisionRegexString = settings.FullExcisionRegexString ?? string.Empty;
8387
parameters.ShouldOutputUntouchedFiles = settings.ShouldOutputUntouchedFiles;
84-
parameters.IsDryRun = settings.ShouldOutputUntouchedFiles;
88+
parameters.IsDryRun = settings.IsDryRun || settings.ShouldOutputUntouchedFiles || settings.Verify;
89+
parameters.Verify = settings.Verify;
8590
parameters.UseFunctionStats = settings.UseFunctionStats;
8691
parameters.DontSkip = settings.DontSkip;
8792
if (settings.RequiredExcisionRatio.HasValue)

ServerCodeExciser/ServerCodeExcisionProcessor.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class ServerCodeExcisionParameters
1616
public string FullExcisionRegexString { get; set; } = string.Empty;
1717
public bool ShouldOutputUntouchedFiles { get; set; } = false;
1818
public bool IsDryRun { get; set; } = false;
19+
public bool Verify { get; set; } = false;
1920
public bool UseFunctionStats { get; set; } = false;
2021
public bool DontSkip { get; set; } = false;
2122
public float RequiredExcisionRatio { get; set; } = -1.0f;
@@ -128,6 +129,23 @@ public EExciserReturnValues ExciseServerCode(string filePattern, IServerCodeExci
128129

129130
var endTime = DateTime.UtcNow;
130131

132+
// In verification mode error codes reverse the normal behavior of the exciser.
133+
// Modifications required -> error
134+
// No modifications required -> success
135+
if (_parameters.Verify)
136+
{
137+
if (globalStats.CharactersExcised > 0)
138+
{
139+
Console.Error.WriteLine("Executed in verification mode. Manual server code exicion is required.");
140+
return EExciserReturnValues.RequiresExcision;
141+
}
142+
else
143+
{
144+
Console.WriteLine("Executed in verification mode. No modifications are required.");
145+
return EExciserReturnValues.Success;
146+
}
147+
}
148+
131149
if (globalStats.CharactersExcised > 0)
132150
{
133151
System.Diagnostics.Debug.Assert(globalStats.TotalNrCharacters > 0, "Something is terribly wrong.");

ServerCodeExcisionCommon/ServerCodeExcisionUtils.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ public enum EExciserReturnValues
8282
UnknownExcisionLanguage,
8383
NothingExcised,
8484
InternalExcisionError,
85-
RequiredExcisionRatioNotReached
85+
RequiredExcisionRatioNotReached,
86+
RequiresExcision
8687
}
8788

8889
public class ExcisionException : Exception

0 commit comments

Comments
 (0)