Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add exit code to the compatibility tool. #45642

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Microsoft.DotNet.ApiCompat
{
internal static class ValidateAssemblies
{
public static void Run(Func<ISuppressionEngine, ISuppressibleLog> logFactory,
public static int Run(Func<ISuppressionEngine, ISuppressibleLog> logFactory,
bool generateSuppressionFile,
bool preserveUnnecessarySuppressions,
bool permitUnnecessarySuppressions,
Expand Down Expand Up @@ -100,6 +100,8 @@ public static void Run(Func<ISuppressionEngine, ISuppressibleLog> logFactory,
{
SuppressionFileHelper.ValidateUnnecessarySuppressions(serviceProvider.SuppressionEngine, serviceProvider.SuppressibleLog);
}

return serviceProvider.SuppressibleLog.HasLoggedErrorSuppressions ? 1 : 0;
}

private static string[]? GetAssemblyReferences(string[][]? assemblyReferences, int counter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Microsoft.DotNet.ApiCompat
{
internal static class ValidatePackage
{
public static void Run(Func<ISuppressionEngine, ISuppressibleLog> logFactory,
public static int Run(Func<ISuppressionEngine, ISuppressibleLog> logFactory,
bool generateSuppressionFile,
bool preserveUnnecessarySuppressions,
bool permitUnnecessarySuppressions,
Expand Down Expand Up @@ -96,6 +96,8 @@ public static void Run(Func<ISuppressionEngine, ISuppressibleLog> logFactory,
{
SuppressionFileHelper.ValidateUnnecessarySuppressions(serviceProvider.SuppressionEngine, serviceProvider.SuppressibleLog);
}

return serviceProvider.SuppressibleLog.HasLoggedErrorSuppressions ? 1 : 0;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ static int Main(string[] args)
(string, string)[]? rightAssembliesTransformationPattern = parseResult.GetValue(rightAssembliesTransformationPatternOption);

SuppressibleConsoleLog logFactory(ISuppressionEngine suppressionEngine) => new(suppressionEngine, verbosity);
ValidateAssemblies.Run(logFactory,
int exitCode = ValidateAssemblies.Run(logFactory,
generateSuppressionFile,
preserveUnnecessarySuppressions,
permitUnnecessarySuppressions,
Expand All @@ -218,6 +218,8 @@ static int Main(string[] args)
rightAssembliesTransformationPattern);

roslynResolver.Unregister();

return exitCode;
});

// Package command
Expand Down Expand Up @@ -319,7 +321,7 @@ static int Main(string[] args)
string[]? baselinePackageFrameworksToIgnore = parseResult.GetValue(baselinePackageFrameworksToIgnoreOption);

SuppressibleConsoleLog logFactory(ISuppressionEngine suppressionEngine) => new(suppressionEngine, verbosity);
ValidatePackage.Run(logFactory,
int exitCode = ValidatePackage.Run(logFactory,
generateSuppressionFile,
preserveUnnecessarySuppressions,
permitUnnecessarySuppressions,
Expand All @@ -342,6 +344,8 @@ static int Main(string[] args)
baselinePackageFrameworksToIgnore);

roslynResolver.Unregister();

return exitCode;
});

rootCommand.Subcommands.Add(packageCommand);
Expand Down
Loading