/// <summary> /// Creates a new compilation with the specified compilation options. /// </summary> public SoalCompilation WithOptions(SoalCompilationOptions options) { var oldOptions = this.Options; bool reuseReferenceManager = oldOptions.CanReuseCompilationReferenceManager(options); bool reuseSyntaxAndDeclarationManager = oldOptions.ScriptClassName == options.ScriptClassName && oldOptions.SourceReferenceResolver == options.SourceReferenceResolver; return(new SoalCompilation( this.CompilationName, options, this.ExternalReferences, this.PreviousSubmission, this.SubmissionReturnType, this.HostObjectType, this.IsSubmission, this.GetUnboundReferenceManager(), reuseReferenceManager, reuseSyntaxAndDeclarationManager ? this.SyntaxAndDeclarations : SyntaxAndDeclarationManager.Create( this.SyntaxAndDeclarations.ExternalSyntaxTrees, options.ScriptClassName, options.SourceReferenceResolver, this.SyntaxAndDeclarations.IsSubmission))); }
private static SoalCompilation Create( string name, SoalCompilationOptions options, IEnumerable <SoalSyntaxTree> syntaxTrees, IEnumerable <MetadataReference> references, SoalCompilation previousSubmission, Type returnType, Type hostObjectType, bool isSubmission) { Debug.Assert(options != null); Debug.Assert(!isSubmission || options.ReferencesSupersedeLowerVersions); var validatedReferences = ValidateReferences <CompilationReference>(references); var compilation = new SoalCompilation( name, options, validatedReferences, previousSubmission, returnType, hostObjectType, isSubmission, referenceManager: null, reuseReferenceManager: false, syntaxAndDeclarations: SyntaxAndDeclarationManager.Create( ImmutableArray <SyntaxTree> .Empty, options.ScriptClassName, options.SourceReferenceResolver, isSubmission)); if (syntaxTrees != null) { compilation = compilation.AddSyntaxTrees(syntaxTrees); } return(compilation); }