1- using System ;
1+ using System ;
22using System . Collections . Generic ;
33using System . IO ;
44using System . Linq ;
5- using System . Reflection ;
65using Microsoft . Build . Framework ;
6+ using Microsoft . Build . Tasks ;
77using Microsoft . Build . Utilities ;
88
99namespace Microsoft . SourceIndexer . Tasks
@@ -30,25 +30,24 @@ public override bool Execute()
3030 }
3131 }
3232
33- private static Type FileMatcher { get ; } = Type . GetType ( "Microsoft.Build.Shared.FileMatcher, Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" ) ;
34-
35- private static Func < string , string , string [ ] > GetFiles { get ; } =
36- GetGetFilesFunction ( ) ;
37-
38- private static Func < string , string , string [ ] > GetGetFilesFunction ( )
33+ private string [ ] GetFiles ( string localPath , string glob )
3934 {
40- var func14 = FileMatcher . GetMethod ( "GetFiles" , BindingFlags . NonPublic | BindingFlags . Static , null , new [ ] { typeof ( string ) , typeof ( string ) } , new ParameterModifier [ 0 ] ) ;
41- if ( func14 != null )
35+ var createItemTask = new CreateItem
4236 {
43- return ( Func < string , string , string [ ] > ) func14 . CreateDelegate ( typeof ( Func < string , string , string [ ] > ) ) ;
44- }
45- var func15 = FileMatcher . GetMethod ( "GetFiles" , BindingFlags . NonPublic | BindingFlags . Static , null , new [ ] { typeof ( string ) , typeof ( string ) , typeof ( IEnumerable < string > ) } , new ParameterModifier [ 0 ] ) ;
46- if ( func15 != null )
37+ BuildEngine = BuildEngine ,
38+ Include = new [ ]
39+ {
40+ new TaskItem ( Path . Combine ( localPath , glob ) )
41+ }
42+ } ;
43+
44+ if ( ! createItemTask . Execute ( ) )
4745 {
48- var f = ( Func < string , string , IEnumerable < string > , string [ ] > ) func15 . CreateDelegate ( typeof ( Func < string , string , IEnumerable < string > , string [ ] > ) ) ;
49- return ( a , b ) => f ( a , b , Enumerable . Empty < string > ( ) ) ;
46+ throw new Exception (
47+ $ "Failed to create items with localPath ' { localPath } ', glob ' { glob } '" ) ;
5048 }
51- throw new MissingMethodException ( "Could not find FileMatcher.GetFiles" ) ;
49+
50+ return createItemTask . Include . Select ( item => item . ItemSpec ) . ToArray ( ) ;
5251 }
5352
5453
0 commit comments