public TypeCollector(string csProjPath, IEnumerable <string> conditinalSymbols, IEnumerable <string> allowCustomTypes, bool disallowInternal, bool generatePropertyTypeEnumOnly, bool disallowInMetadata, bool generateComparerKeyTypeEnumOnly, string namespaceRoot) { this.disallowInMetadata = disallowInMetadata; this.csProjPath = csProjPath; this.allowCustomTypes = new HashSet <string>(allowCustomTypes); this.generateComparerKeyTypeEnumOnly = generateComparerKeyTypeEnumOnly; this.namespaceRoot = namespaceRoot; this.disallowInternal = disallowInternal; var compilation = RoslynExtensions.GetCompilationFromProject(csProjPath, conditinalSymbols.Concat(new[] { CodegeneratorOnlyPreprocessorSymbol }).ToArray()).GetAwaiter().GetResult(); targetTypes = compilation.GetNamedTypeSymbols() .Where(x => { if (x.DeclaredAccessibility == Accessibility.Public) { return(true); } if (!disallowInternal) { return(x.DeclaredAccessibility == Accessibility.Friend); } return(false); }) .Where(x => (!generatePropertyTypeEnumOnly && x.TypeKind == TypeKind.Enum) || ((x.TypeKind == TypeKind.Class) && x.GetAttributes().FindAttributeShortName(UnionAttributeShortName) != null) || ((x.TypeKind == TypeKind.Interface) && x.GetAttributes().FindAttributeShortName(UnionAttributeShortName) != null) || ((x.TypeKind == TypeKind.Class) && x.GetAttributes().FindAttributeShortName(ZeroFormattableAttributeShortName) != null) || ((x.TypeKind == TypeKind.Struct) && x.GetAttributes().FindAttributeShortName(ZeroFormattableAttributeShortName) != null) ) .ToLookup(x => x.TypeKind); }
public TypeCollector(string csProjPath) { this.csProjPath = csProjPath; var compilation = RoslynExtensions.GetCompilationFromProject(csProjPath, CodegeneratorOnlyPreprocessorSymbol).GetAwaiter().GetResult(); targetTypes = compilation.GetNamedTypeSymbols() .Where(x => (x.TypeKind == TypeKind.Enum) || ((x.TypeKind == TypeKind.Class) && x.GetAttributes().FindAttributeShortName(ZeroFormattableAttributeShortName) != null) || ((x.TypeKind == TypeKind.Struct) && x.GetAttributes().FindAttributeShortName(ZeroFormattableAttributeShortName) != null) ) .ToLookup(x => x.TypeKind); }
public TypeCollector(string csProjPath, IEnumerable <string> conditinalSymbols, IEnumerable <string> allowCustomTypes) { this.csProjPath = csProjPath; this.allowCustomTypes = new HashSet <string>(allowCustomTypes); var compilation = RoslynExtensions.GetCompilationFromProject(csProjPath, conditinalSymbols.Concat(new[] { CodegeneratorOnlyPreprocessorSymbol }).ToArray()).GetAwaiter().GetResult(); targetTypes = compilation.GetNamedTypeSymbols() .Where(x => (x.TypeKind == TypeKind.Enum) || ((x.TypeKind == TypeKind.Class) && x.GetAttributes().FindAttributeShortName(UnionAttributeShortName) != null) || ((x.TypeKind == TypeKind.Class) && x.GetAttributes().FindAttributeShortName(ZeroFormattableAttributeShortName) != null) || ((x.TypeKind == TypeKind.Struct) && x.GetAttributes().FindAttributeShortName(ZeroFormattableAttributeShortName) != null) ) .ToLookup(x => x.TypeKind); }