@@ -45,23 +45,15 @@ public sealed class DotNetMSBuildSdkResolver : SdkResolver
45
45
/// VS-driven CI pipelines, we probe and invoke only if the expected method is present.
46
46
/// Once we can update our MSBuild API dependency this can go away.
47
47
/// </summary>
48
- private static Func <
49
- SdkResultFactory ,
50
- // path to sdk
51
- string ,
52
- // sdk version
53
- string ? ,
54
- // properties to add
55
- IDictionary < string , string ? > ? ,
56
- // items to add
57
- IDictionary < string , SdkResultItem > ? ,
58
- // warnings
59
- List < string > ? ,
60
- // environment variables to add
61
- IDictionary < string , string ? > ? ,
62
- SdkResult > ? _factorySuccessFunc = TryLocateNewMSBuildFactory ( ) ;
63
-
64
- private static Func < SdkResultFactory , string , string ? , IDictionary < string , string ? > ? , IDictionary < string , SdkResultItem > ? , List < string > ? , IDictionary < string , string ? > ? , SdkResult > ? TryLocateNewMSBuildFactory ( )
48
+ private static UpdatedSdkResultFactorySuccess ? _factorySuccessFunc = TryLocateNewMSBuildFactory ( ) ;
49
+
50
+ /// <summary>
51
+ /// This represents the 'open delegate' form of the updated SdkResultFactory.IndicateSuccess method with environment variable support.
52
+ /// Because it is an open delegate, we can provide an object instance to be called as the first argument.
53
+ /// </summary>
54
+ public delegate SdkResult UpdatedSdkResultFactorySuccess ( SdkResultFactory factory , string sdkPath , string ? sdkVersion , IDictionary < string , string ? > ? propertiesToAdd , IDictionary < string , SdkResultItem > ? itemsToAdd , List < string > ? warnings , IDictionary < string , string ? > ? environmentVariablesToAdd ) ;
55
+
56
+ private static UpdatedSdkResultFactorySuccess ? TryLocateNewMSBuildFactory ( )
65
57
{
66
58
if ( typeof ( SdkResultFactory ) . GetMethod ( "IndicateSuccess" , [
67
59
typeof ( string ) , // path to sdk
@@ -72,10 +64,10 @@ private static Func<
72
64
typeof ( IDictionary < string , string > ) // environment variables to add
73
65
] ) is MethodInfo m )
74
66
{
75
- return ( factory , path , version , properties , items , warnings , environmentVariables ) =>
76
- {
77
- return ( SdkResult ) m . Invoke ( factory , [ path , version , properties , items , warnings , environmentVariables ] ) ;
78
- } ;
67
+ return Delegate . CreateDelegate (
68
+ typeof ( Func < SdkResultFactory , string , string ? , IDictionary < string , string ? > ? , IDictionary < string , SdkResultItem > ? , List < string > ? , IDictionary < string , string ? > ? , SdkResult > ) ,
69
+ null ,
70
+ m ) as UpdatedSdkResultFactorySuccess ;
79
71
}
80
72
return null ;
81
73
}
@@ -340,7 +332,7 @@ private sealed class CachedState
340
332
}
341
333
if ( _factorySuccessFunc != null )
342
334
{
343
- return _factorySuccessFunc . Invoke ( factory , msbuildSdkDir , netcoreSdkVersion , propertiesToAdd , itemsToAdd , warnings , environmentVariablesToAdd ) ;
335
+ return _factorySuccessFunc ( factory , msbuildSdkDir , netcoreSdkVersion , propertiesToAdd , itemsToAdd , warnings , environmentVariablesToAdd ) ;
344
336
}
345
337
else
346
338
{
0 commit comments