@@ -45,23 +45,15 @@ public sealed class DotNetMSBuildSdkResolver : SdkResolver
4545 /// VS-driven CI pipelines, we probe and invoke only if the expected method is present.
4646 /// Once we can update our MSBuild API dependency this can go away.
4747 /// </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 ( )
6557 {
6658 if ( typeof ( SdkResultFactory ) . GetMethod ( "IndicateSuccess" , [
6759 typeof ( string ) , // path to sdk
@@ -72,10 +64,10 @@ private static Func<
7264 typeof ( IDictionary < string , string > ) // environment variables to add
7365 ] ) is MethodInfo m )
7466 {
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 ;
7971 }
8072 return null ;
8173 }
@@ -340,7 +332,7 @@ private sealed class CachedState
340332 }
341333 if ( _factorySuccessFunc != null )
342334 {
343- return _factorySuccessFunc . Invoke ( factory , msbuildSdkDir , netcoreSdkVersion , propertiesToAdd , itemsToAdd , warnings , environmentVariablesToAdd ) ;
335+ return _factorySuccessFunc ( factory , msbuildSdkDir , netcoreSdkVersion , propertiesToAdd , itemsToAdd , warnings , environmentVariablesToAdd ) ;
344336 }
345337 else
346338 {
0 commit comments