public static bool Execute( string[] seeds, string referenceAssembly, string[] compileFiles, string defineConstants, string outputSourcePath, TaskLoggingHelper logger, bool ignoreMissingTypes = false, string[] ignoreMissingTypesList = null, string[] OmitTypes = null, ITaskItem[] seedTypePreferencesList = null) { var nameTable = new NameTable(); var internFactory = new InternFactory(); Dictionary <string, string> seedTypePreferences = ParseSeedTypePreferences(seedTypePreferencesList, logger); using (var contractHost = new HostEnvironment(nameTable, internFactory)) using (var seedHost = new HostEnvironment(nameTable, internFactory)) { IAssembly contractAssembly = contractHost.LoadAssembly(referenceAssembly); IEnumerable <string> referenceTypes = GetPublicVisibleTypes(contractAssembly); if (OmitTypes != null) { referenceTypes = referenceTypes.Where(type => !OmitTypes.Contains(type)); } IAssembly[] seedAssemblies = LoadAssemblies(seedHost, seeds).ToArray(); var seedTypes = GenerateTypeTable(seedAssemblies); var sourceGenerator = new SourceGenerator(referenceTypes, seedTypes, seedTypePreferences, outputSourcePath, ignoreMissingTypesList, logger); return(sourceGenerator.GenerateSource(compileFiles, ParseDefineConstants(defineConstants), ignoreMissingTypes)); } }
public static bool Execute( string[] seeds, string contractAssembly, string[] compileFiles, string defineConstants, string langVersion, string outputSourcePath, ILog logger, bool ignoreMissingTypes = false, string[] ignoreMissingTypesList = null, string[] OmitTypes = null, ITaskItem[] seedTypePreferencesList = null) { Dictionary <string, string> seedTypePreferences = ParseSeedTypePreferences(seedTypePreferencesList, logger); IEnumerable <string> referenceTypes = GetPublicVisibleTypes(contractAssembly, includeTypeForwards: true); // Normalizing and Removing Relative Segments from the seed paths. string[] distinctSeeds = seeds.Select(seed => Path.GetFullPath(seed)).Distinct().ToArray(); string[] seedNames = distinctSeeds.Select(seed => Path.GetFileName(seed)).ToArray(); if (distinctSeeds.Count() != seedNames.Distinct(StringComparer.InvariantCultureIgnoreCase).Count()) { IEnumerable <string> duplicates = seedNames.GroupBy(x => x) .Where(g => g.Count() > 1) .Select(y => y.Key); logger.LogError("There are multiple versions of these assemblies: {0}. Please provide a single version.", string.Join(", ", duplicates)); return(false); } IReadOnlyDictionary <string, IList <string> > seedTypes = GenerateTypeTable(distinctSeeds); if (OmitTypes != null) { referenceTypes = referenceTypes.Where(type => !OmitTypes.Contains(type)); } var sourceGenerator = new SourceGenerator(referenceTypes, seedTypes, seedTypePreferences, outputSourcePath, ignoreMissingTypesList, logger); return(sourceGenerator.GenerateSource(compileFiles, ParseDefineConstants(defineConstants), langVersion, ignoreMissingTypes)); }