66using System . Collections . Generic ;
77using System . ComponentModel ;
88using System . Diagnostics ;
9+ using System . Diagnostics . CodeAnalysis ;
910using System . IO ;
1011using System . Linq ;
1112using System . Runtime . InteropServices ;
1213
14+ #nullable enable
15+
1316namespace BenchmarkDotNet . Validators
1417{
1518 internal static class DotNetSdkValidator
@@ -26,15 +29,15 @@ public static IEnumerable<ValidationError> ValidateCoreSdks(string? customDotNet
2629 var requiredSdkVersion = benchmark . GetRuntime ( ) . RuntimeMoniker . GetRuntimeVersion ( ) ;
2730 if ( ! GetInstalledDotNetSdks ( customDotNetCliPath ) . Any ( sdk => sdk >= requiredSdkVersion ) )
2831 {
29- yield return new ValidationError ( true , $ "The required .NET Core SDK version { requiredSdkVersion } or higher for runtime moniker { benchmark . Job . Environment . Runtime . RuntimeMoniker } is not installed.", benchmark ) ;
32+ yield return new ValidationError ( true , $ "The required .NET Core SDK version { requiredSdkVersion } or higher for runtime moniker { benchmark . Job . Environment . Runtime ! . RuntimeMoniker } is not installed.", benchmark ) ;
3033 }
3134 }
3235
3336 public static IEnumerable < ValidationError > ValidateFrameworkSdks ( BenchmarkCase benchmark )
3437 {
3538 var targetRuntime = benchmark . Job . Environment . HasValue ( EnvironmentMode . RuntimeCharacteristic )
36- ? benchmark . Job . Environment . Runtime
37- : ClrRuntime . GetTargetOrCurrentVersion ( benchmark . Descriptor . WorkloadMethod . DeclaringType . Assembly ) ;
39+ ? benchmark . Job . Environment . Runtime !
40+ : ClrRuntime . GetTargetOrCurrentVersion ( benchmark . Descriptor . WorkloadMethod . DeclaringType ! . Assembly ) ;
3841 var requiredSdkVersion = targetRuntime . RuntimeMoniker . GetRuntimeVersion ( ) ;
3942
4043 var installedVersionString = cachedFrameworkSdks . Value . FirstOrDefault ( ) ;
@@ -44,7 +47,7 @@ public static IEnumerable<ValidationError> ValidateFrameworkSdks(BenchmarkCase b
4447 }
4548 }
4649
47- public static bool IsCliPathInvalid ( string customDotNetCliPath , BenchmarkCase benchmarkCase , out ValidationError ? validationError )
50+ public static bool IsCliPathInvalid ( string ? customDotNetCliPath , BenchmarkCase benchmarkCase , [ NotNullWhen ( true ) ] out ValidationError ? validationError )
4851 {
4952 validationError = null ;
5053
@@ -71,7 +74,7 @@ public static bool IsCliPathInvalid(string customDotNetCliPath, BenchmarkCase be
7174
7275 private static IEnumerable < Version > GetInstalledDotNetSdks ( string ? customDotNetCliPath )
7376 {
74- string dotnetExecutable = string . IsNullOrEmpty ( customDotNetCliPath ) ? "dotnet" : customDotNetCliPath ;
77+ string dotnetExecutable = string . IsNullOrEmpty ( customDotNetCliPath ) ? "dotnet" : customDotNetCliPath ! ;
7578 var startInfo = new ProcessStartInfo ( dotnetExecutable , "--list-sdks" )
7679 {
7780 RedirectStandardOutput = true ,
@@ -146,13 +149,13 @@ private static void Get45PlusFromRegistry(List<string> versions)
146149
147150 if ( ndpKey . GetValue ( "Version" ) != null )
148151 {
149- versions . Add ( ndpKey . GetValue ( "Version" ) . ToString ( ) ) ;
152+ versions . Add ( ndpKey . GetValue ( "Version" ) ! . ToString ( ) ! ) ;
150153 }
151154 else
152155 {
153156 if ( ndpKey . GetValue ( "Release" ) != null )
154157 {
155- versions . Add ( CheckFor45PlusVersion ( ( int ) ndpKey . GetValue ( "Release" ) ) ) ;
158+ versions . Add ( CheckFor45PlusVersion ( ( int ) ndpKey . GetValue ( "Release" ) ! ) ) ;
156159 }
157160 }
158161 }
0 commit comments