public static CompileSources ( |
||
compilation | ||
moduleBuilder | ||
emittingPdb | bool | |
hasDeclarationErrors | bool | |
diagnostics | DiagnosticBag | |
cancellationToken | ||
리턴 | void |
internal override bool CompileMethods(CommonPEModuleBuilder moduleBuilder, bool emittingPdb, bool emitMetadataOnly, bool emitTestCoverageData, DiagnosticBag diagnostics, Predicate <ISymbol> filterOpt, CancellationToken cancellationToken) { // The diagnostics should include syntax and declaration errors. We insert these before calling Emitter.Emit, so that the emitter // does not attempt to emit if there are declaration errors (but we do insert all errors from method body binding...) bool hasDeclarationErrors = false; // !FilterAndAppendDiagnostics(diagnostics, GetDiagnostics(CompilationStage.Declare, true, cancellationToken)); var moduleBeingBuilt = (PEModuleBuilder)moduleBuilder; if (emitMetadataOnly) { throw new NotImplementedException(); } if (emittingPdb) { if (!CreateDebugDocuments( moduleBeingBuilt.DebugDocumentsBuilder, moduleBeingBuilt.EmbeddedTexts.Concat(CollectAdditionalEmbeddedTexts()), diagnostics)) { return(false); } } // Use a temporary bag so we don't have to refilter pre-existing diagnostics. DiagnosticBag methodBodyDiagnosticBag = DiagnosticBag.GetInstance(); // Perform initial bind of method bodies in spite of earlier errors. This is the same // behavior as when calling GetDiagnostics() try { SourceCompiler.CompileSources( this, moduleBeingBuilt, emittingPdb, hasDeclarationErrors, methodBodyDiagnosticBag, cancellationToken); bool hasMethodBodyErrorOrWarningAsError = !FilterAndAppendAndFreeDiagnostics(diagnostics, ref methodBodyDiagnosticBag); if (hasDeclarationErrors || hasMethodBodyErrorOrWarningAsError) { return(false); } return(true); } catch (Exception ex) { this.TrackException(ex); throw; } }
internal override bool CompileImpl(CommonPEModuleBuilder moduleBuilder, Stream win32Resources, Stream xmlDocStream, bool emittingPdb, DiagnosticBag diagnostics, Predicate <ISymbol> filterOpt, CancellationToken cancellationToken) { // The diagnostics should include syntax and declaration errors. We insert these before calling Emitter.Emit, so that the emitter // does not attempt to emit if there are declaration errors (but we do insert all errors from method body binding...) bool hasDeclarationErrors = false; // !FilterAndAppendDiagnostics(diagnostics, GetDiagnostics(CompilationStage.Declare, true, cancellationToken)); var moduleBeingBuilt = (PEModuleBuilder)moduleBuilder; if (moduleBeingBuilt.EmitOptions.EmitMetadataOnly) { throw new NotImplementedException(); } // Perform initial bind of method bodies in spite of earlier errors. This is the same // behavior as when calling GetDiagnostics() // Use a temporary bag so we don't have to refilter pre-existing diagnostics. DiagnosticBag methodBodyDiagnosticBag = DiagnosticBag.GetInstance(); SourceCompiler.CompileSources( this, moduleBeingBuilt, emittingPdb, hasDeclarationErrors, methodBodyDiagnosticBag, cancellationToken); SetupWin32Resources(moduleBeingBuilt, win32Resources, methodBodyDiagnosticBag); ReportManifestResourceDuplicates( moduleBeingBuilt.ManifestResources, SourceAssembly.Modules.Skip(1).Select((m) => m.Name), //all modules except the first one AddedModulesResourceNames(methodBodyDiagnosticBag), methodBodyDiagnosticBag); bool hasMethodBodyErrorOrWarningAsError = !FilterAndAppendAndFreeDiagnostics(diagnostics, ref methodBodyDiagnosticBag); if (hasDeclarationErrors || hasMethodBodyErrorOrWarningAsError) { return(false); } cancellationToken.ThrowIfCancellationRequested(); // Use a temporary bag so we don't have to refilter pre-existing diagnostics. DiagnosticBag xmlDiagnostics = DiagnosticBag.GetInstance(); string assemblyName = FileNameUtilities.ChangeExtension(moduleBeingBuilt.EmitOptions.OutputNameOverride, extension: null); DocumentationCommentCompiler.WriteDocumentationCommentXml(this, assemblyName, xmlDocStream, xmlDiagnostics, cancellationToken); if (!FilterAndAppendAndFreeDiagnostics(diagnostics, ref xmlDiagnostics)) { return(false); } //// Use a temporary bag so we don't have to refilter pre-existing diagnostics. //DiagnosticBag importDiagnostics = DiagnosticBag.GetInstance(); //this.ReportUnusedImports(importDiagnostics, cancellationToken); //if (!FilterAndAppendAndFreeDiagnostics(diagnostics, ref importDiagnostics)) //{ // Debug.Assert(false, "Should never produce an error"); // return false; //} return(true); }