public SymbolImplementationTransformer(ISymbolTransformer transformer) { _transformer = transformer; }
public SymbolImplementationTransformer(ISymbolTransformer transformer) { _transformer = transformer; }
private void BuildMetadata() { if ((_options.Resources != null) && (_options.Resources.Count != 0)) { ResourcesBuilder resourcesBuilder = new ResourcesBuilder(_symbols); resourcesBuilder.BuildResources(_options.Resources); } MetadataBuilder mdBuilder = new MetadataBuilder(this); _appSymbols = mdBuilder.BuildMetadata(_compilationUnitList, _symbols, _options); // Check if any of the types defined in this assembly conflict. Dictionary <string, TypeSymbol> types = new Dictionary <string, TypeSymbol>(); foreach (TypeSymbol appType in _appSymbols) { if ((appType.IsApplicationType == false) || (appType.Type == SymbolType.Delegate)) { // Skip the check for types that are marked as imported, as they // aren't going to be generated into the script. // Delegates are implicitly imported types, as they're never generated into // the script. continue; } if ((appType.Type == SymbolType.Class) && (((ClassSymbol)appType).PrimaryPartialClass != appType)) { // Skip the check for partial types, since they should only be // checked once. continue; } // TODO: We could allow conflicting types as long as both aren't public // since they won't be on the exported types list. Internal types that // conflict could be generated using full name. string name = appType.GeneratedName; if (types.ContainsKey(name)) { string error = "The type '" + appType.FullName + "' conflicts with with '" + types[name].FullName + "' as they have the same name."; ((IErrorHandler)this).ReportError(error, null); } else { types[name] = appType; } } // Capture whether there are any test types in the project // when not compiling the test flavor script. This is used to determine // if the test flavor script should be compiled in the build task. if (_options.IncludeTests == false) { foreach (TypeSymbol appType in _appSymbols) { if (appType.IsApplicationType && appType.IsTestType) { _options.HasTestTypes = true; } } } #if DEBUG if (_options.InternalTestType == "metadata") { StringWriter testWriter = new StringWriter(); testWriter.WriteLine("Metadata"); testWriter.WriteLine("================================================================"); SymbolSetDumper symbolDumper = new SymbolSetDumper(testWriter); symbolDumper.DumpSymbols(_symbols); testWriter.WriteLine(); testWriter.WriteLine(); _testOutput = testWriter.ToString(); } #endif // DEBUG ISymbolTransformer transformer = null; if (_options.Minimize) { transformer = new SymbolObfuscator(); } else { transformer = new SymbolInternalizer(); } if (transformer != null) { SymbolSetTransformer symbolSetTransformer = new SymbolSetTransformer(transformer); ICollection <Symbol> transformedSymbols = symbolSetTransformer.TransformSymbolSet(_symbols, /* useInheritanceOrder */ true); #if DEBUG if (_options.InternalTestType == "minimizationMap") { StringWriter testWriter = new StringWriter(); testWriter.WriteLine("Minimization Map"); testWriter.WriteLine("================================================================"); List <Symbol> sortedTransformedSymbols = new List <Symbol>(transformedSymbols); sortedTransformedSymbols.Sort(delegate(Symbol s1, Symbol s2) { return(String.Compare(s1.Name, s2.Name)); }); foreach (Symbol transformedSymbol in sortedTransformedSymbols) { Debug.Assert(transformedSymbol is MemberSymbol); testWriter.WriteLine(" Member '" + transformedSymbol.Name + "' renamed to '" + transformedSymbol.GeneratedName + "'"); } testWriter.WriteLine(); testWriter.WriteLine(); _testOutput = testWriter.ToString(); } #endif // DEBUG } }
//TODO: Look at removing the internal testing type mechanism in favour of testing the compiler correctly. private void BuildMetadata() { if (options.Resources != null && options.Resources.Count != 0) { ResourcesBuilder resourcesBuilder = new ResourcesBuilder(symbols); resourcesBuilder.BuildResources(options.Resources); } MetadataBuilder mdBuilder = new MetadataBuilder(this); appSymbols = mdBuilder.BuildMetadata(compilationUnitList, symbols, options); // Check if any of the types defined in this assembly conflict. Dictionary <string, TypeSymbol> types = new Dictionary <string, TypeSymbol>(); foreach (TypeSymbol appType in appSymbols) { if (appType.IsApplicationType == false || appType.Type == SymbolType.Delegate) { // Skip the check for types that are marked as imported, as they // aren't going to be generated into the script. // Delegates are implicitly imported types, as they're never generated into // the script. continue; } if (appType.Type == SymbolType.Class && ((ClassSymbol)appType).PrimaryPartialClass != appType) { // Skip the check for partial types, since they should only be // checked once. continue; } // TODO: We could allow conflicting types as long as both aren't public // since they won't be on the exported types list. Internal types that // conflict could be generated using full name. string name = appType.GeneratedName; if (types.ContainsKey(name)) { ((IErrorHandler)this).ReportGeneralError(string.Format(DSharpStringResources.CONFLICTING_TYPE_NAME_ERROR_FORMAT, appType.FullName, types[name].FullName)); } else { types[name] = appType; } } ISymbolTransformer transformer = null; if (options.Minimize) { transformer = new SymbolObfuscator(); } else { transformer = new SymbolInternalizer(); } if (transformer != null) { SymbolSetTransformer symbolSetTransformer = new SymbolSetTransformer(transformer); ICollection <Symbol> transformedSymbols = symbolSetTransformer.TransformSymbolSet(symbols, /* useInheritanceOrder */ true); } }
public SymbolSetTransformer(ISymbolTransformer transformer, bool excludeImportedTypes) { _transformer = transformer; _excludeImportedTypes = excludeImportedTypes; }
public SymbolSetTransformer(ISymbolTransformer transformer) : this(transformer, /* excludeImportedTypes */ true) { }