15 instantiations of ScriptOptions
Microsoft.CodeAnalysis.Scripting (15)
Hosting\CommandLine\CommandLineRunner.cs (1)
166return new ScriptOptions(
ScriptOptions.cs (14)
25public static ScriptOptions Default { get; } = new ScriptOptions( 206=> (FilePath == filePath) ? this : new ScriptOptions(this) { FilePath = filePath ?? "" }; 216=> MetadataReferences.Equals(references) ? this : new ScriptOptions(this) { MetadataReferences = CheckImmutableArray(references, nameof(references)) }; 311=> MetadataResolver == resolver ? this : new ScriptOptions(this) { MetadataResolver = resolver }; 317=> SourceResolver == resolver ? this : new ScriptOptions(this) { SourceResolver = resolver }; 324=> Imports.Equals(imports) ? this : new ScriptOptions(this) { Imports = CheckImmutableArray(imports, nameof(imports)) }; 358=> emitDebugInformation == EmitDebugInformation ? this : new ScriptOptions(this) { EmitDebugInformation = emitDebugInformation }; 364=> encoding == FileEncoding ? this : new ScriptOptions(this) { FileEncoding = encoding }; 370=> optimizationLevel == OptimizationLevel ? this : new ScriptOptions(this) { OptimizationLevel = optimizationLevel }; 376=> allowUnsafe == AllowUnsafe ? this : new ScriptOptions(this) { AllowUnsafe = allowUnsafe }; 382=> checkOverflow == CheckOverflow ? this : new ScriptOptions(this) { CheckOverflow = checkOverflow }; 388=> warningLevel == WarningLevel ? this : new ScriptOptions(this) { WarningLevel = warningLevel }; 391=> parseOptions == ParseOptions ? this : new ScriptOptions(this) { ParseOptions = parseOptions }; 394=> new ScriptOptions(this) { CreateFromFileFunc = createFromFileFunc };
221 references to ScriptOptions
Microsoft.CodeAnalysis.CSharp.Scripting (11)
CSharpScript.cs (8)
33public static Script<T> Create<T>(string code, ScriptOptions options = null, Type globalsType = null, InteractiveAssemblyLoader assemblyLoader = null) 50public static Script<T> Create<T>(Stream code, ScriptOptions options = null, Type globalsType = null, InteractiveAssemblyLoader assemblyLoader = null) 65public static Script<object> Create(string code, ScriptOptions options = null, Type globalsType = null, InteractiveAssemblyLoader assemblyLoader = null) 81public static Script<object> Create(Stream code, ScriptOptions options = null, Type globalsType = null, InteractiveAssemblyLoader assemblyLoader = null) 98public static Task<ScriptState<T>> RunAsync<T>(string code, ScriptOptions options = null, object globals = null, Type globalsType = null, CancellationToken cancellationToken = default(CancellationToken)) 112public static Task<ScriptState<object>> RunAsync(string code, ScriptOptions options = null, object globals = null, Type globalsType = null, CancellationToken cancellationToken = default(CancellationToken)) 128public static Task<T> EvaluateAsync<T>(string code, ScriptOptions options = null, object globals = null, Type globalsType = null, CancellationToken cancellationToken = default(CancellationToken)) 143public static Task<object> EvaluateAsync(string code, ScriptOptions options = null, object globals = null, Type globalsType = null, CancellationToken cancellationToken = default(CancellationToken))
Hosting\CSharpReplServiceProvider.cs (1)
27public override Script<T> CreateScript<T>(string code, ScriptOptions options, Type globalsTypeOpt, InteractiveAssemblyLoader assemblyLoader)
ScriptOptionsExtensions.cs (2)
14public static ScriptOptions WithLanguageVersion(this ScriptOptions options, LanguageVersion languageVersion)
Microsoft.CodeAnalysis.CSharp.Scripting.Desktop.UnitTests (12)
InteractiveSessionReferencesTests.cs (12)
43var options = ScriptOptions.AddImports("System.Diagnostics"); 62var newOptions = s0.Script.Options.AddReferences(typeof(Process).Assembly); 121var options = ScriptOptions.WithMetadataResolver(ScriptMetadataResolver.WithSearchPaths(RuntimeEnvironment.GetRuntimeDirectory())); 140var options = ScriptOptions; 162var options = ScriptOptions. 182var options0 = ScriptOptions.AddReferences( 197var options1 = options0.AddReferences(typeof(System.Xml.XmlDocument).Assembly); 205var options2 = options1.AddReferences("System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"); 213var options3 = options2.AddReferences(typeof(System.Windows.Forms.Form).Assembly.Location); 225var options = ScriptOptions. 479var options = ScriptOptions.AddReferences(badTypeRef); 498var options = ScriptOptions.
Microsoft.CodeAnalysis.CSharp.Scripting.UnitTests (36)
InteractiveSessionTests.cs (10)
211var options = ScriptOptions. 463var options = ScriptOptions.AddImports("System"); 1000var options = ScriptOptions.AddReferences( 1115var options = ScriptOptions. 1133var options = ScriptOptions. 1160var options = ScriptOptions.WithLanguageVersion(MessageID.IDS_FeatureAndPattern.RequiredVersion()); 1366var options = ScriptOptions. 1377var options = ScriptOptions. 1392var options = ScriptOptions.AddImports("?1", "?2"); 1446var options = ScriptOptions.AddReferences(HostAssembly);
ScriptOptionsTests.cs (6)
22var options = ScriptOptions.Default.WithLanguageVersion(LanguageVersion.CSharp8); 29var options = ScriptOptions.Default.WithLanguageVersion(LanguageVersion.CSharp8); 36var options = ScriptOptions.Default.WithParseOptions(new VisualBasicParseOptions(kind: SourceCodeKind.Script, languageVersion: VisualBasic.LanguageVersion.Latest));
ScriptTests.cs (20)
651var options = ScriptOptions.WithSourceResolver(resolver); 674var options = ScriptOptions.WithSourceResolver(resolver); 697var options = ScriptOptions.WithSourceResolver(resolver); 718var options = ScriptOptions.WithSourceResolver(resolver); 753var options = ScriptOptions.WithSourceResolver(resolver); 790var options = ScriptOptions.WithSourceResolver(resolver); 837var options = ScriptOptions.WithSourceResolver(resolver); 851var opts = ScriptOptions.WithEmitDebugInformation(true).WithFilePath("debug.csx").WithFileEncoding(null); 865var opts = ScriptOptions.WithEmitDebugInformation(true).WithFilePath("debug.csx").WithFileEncoding(Encoding.UTF8); 872var opts = ScriptOptions.WithEmitDebugInformation(false).WithFilePath(null).WithFileEncoding(null); 879var opts = ScriptOptions.WithEmitDebugInformation(false).WithFilePath("debug.csx").WithFileEncoding(Encoding.UTF8); 887var opts = ScriptOptions.WithEmitDebugInformation(true).WithFilePath("debug.csx"); 894var opts = ScriptOptions.WithEmitDebugInformation(false).WithFilePath("debug.csx"); 902var opts = ScriptOptions.WithEmitDebugInformation(true).WithFileEncoding(null); 910var opts = ScriptOptions.WithEmitDebugInformation(true).WithFileEncoding(Encoding.UTF8); 917var opts = ScriptOptions.WithEmitDebugInformation(false).WithFileEncoding(null); 924var opts = ScriptOptions.WithEmitDebugInformation(false).WithFileEncoding(Encoding.UTF8); 932var opts = ScriptOptions.WithEmitDebugInformation(true); 939var opts = ScriptOptions.WithEmitDebugInformation(false); 947var options = ScriptOptions.WithSourceResolver(resolver);
Microsoft.CodeAnalysis.InteractiveHost (7)
Interactive\Core\InteractiveHost.Service.cs (7)
70internal readonly ScriptOptions ScriptOptions; 74ScriptOptions scriptOptions, 99internal EvaluationState WithOptions(ScriptOptions options) 136scriptOptions: ScriptOptions.Default.WithMetadataResolver(new ScriptMetadataResolver(referenceResolver)), 439var newOptions = state.ScriptOptions; 651private Script<object>? TryCompile(Script? previousScript, string code, string? path, ScriptOptions options) 657var scriptOptions = options.WithFilePath(path);
Microsoft.CodeAnalysis.Scripting (88)
Hosting\CommandLine\CommandLineHelpers.cs (2)
20internal static ScriptOptions RemoveImportsAndReferences(this ScriptOptions options)
Hosting\CommandLine\CommandLineRunner.cs (7)
130var scriptOptions = GetScriptOptions(Compiler.Arguments, scriptPathOpt, Compiler.MessageProvider, diagnosticsInfos, emitDebugInformation); 152private ScriptOptions? GetScriptOptions(CommandLineArguments arguments, string? scriptPathOpt, CommonMessageProvider messageProvider, List<DiagnosticInfo> diagnostics, bool emitDebugInformation) 202private int RunScript(ScriptOptions? options, SourceText? code, ErrorLogger? errorLogger, CancellationToken cancellationToken) 224private void RunInteractiveLoop(ScriptOptions options, string? initialScriptCodeOpt, CancellationToken cancellationToken) 296private void BuildAndRun(Script<object> newScript, InteractiveScriptGlobals globals, ref ScriptState<object>? state, ref ScriptOptions options, bool displayResult, CancellationToken cancellationToken) 322private static ScriptOptions UpdateOptions(ScriptOptions options, InteractiveScriptGlobals globals)
Hosting\ReplServiceProvider.cs (1)
21public abstract Script<T> CreateScript<T>(string code, ScriptOptions options, Type globalsTypeOpt, InteractiveAssemblyLoader assemblyLoader);
Script.cs (16)
40internal Script(ScriptCompiler compiler, ScriptBuilder builder, SourceText sourceText, ScriptOptions options, Type globalsTypeOpt, Script previousOpt) 55internal static Script<T> CreateInitialScript<T>(ScriptCompiler compiler, SourceText sourceText, ScriptOptions optionsOpt, Type globalsTypeOpt, InteractiveAssemblyLoader assemblyLoaderOpt) 57return new Script<T>(compiler, new ScriptBuilder(assemblyLoaderOpt ?? new InteractiveAssemblyLoader()), sourceText, optionsOpt ?? ScriptOptions.Default, globalsTypeOpt, previousOpt: null); 70public ScriptOptions Options { get; } 95public Script WithOptions(ScriptOptions options) => WithOptionsInternal(options); 96internal abstract Script WithOptionsInternal(ScriptOptions options); 101public Script<object> ContinueWith(string code, ScriptOptions options = null) 109public Script<object> ContinueWith(Stream code, ScriptOptions options = null) 115public Script<TResult> ContinueWith<TResult>(string code, ScriptOptions options = null) 126public Script<TResult> ContinueWith<TResult>(Stream code, ScriptOptions options = null) 134private static ScriptOptions InheritOptions(ScriptOptions previous) 244/// This can be different than the list of references defined by the <see cref="ScriptOptions"/> instance. 345internal Script(ScriptCompiler compiler, ScriptBuilder builder, SourceText sourceText, ScriptOptions options, Type globalsTypeOpt, Script previousOpt) 352public new Script<T> WithOptions(ScriptOptions options) 357internal override Script WithOptionsInternal(ScriptOptions options) => WithOptions(options);
ScriptOptions.cs (58)
25public static ScriptOptions Default { get; } = new ScriptOptions( 181private ScriptOptions(ScriptOptions other) 203/// Creates a new <see cref="ScriptOptions"/> with the <see cref="FilePath"/> changed. 205public ScriptOptions WithFilePath(string? filePath) 212/// Creates a new <see cref="ScriptOptions"/> with the references changed. 215private ScriptOptions WithReferences(ImmutableArray<MetadataReference> references) 219/// Creates a new <see cref="ScriptOptions"/> with the references changed. 222public ScriptOptions WithReferences(IEnumerable<MetadataReference> references) 226/// Creates a new <see cref="ScriptOptions"/> with the references changed. 229public ScriptOptions WithReferences(params MetadataReference[] references) 233/// Creates a new <see cref="ScriptOptions"/> with references added. 236public ScriptOptions AddReferences(IEnumerable<MetadataReference> references) 240/// Creates a new <see cref="ScriptOptions"/> with references added. 242public ScriptOptions AddReferences(params MetadataReference[] references) 246/// Creates a new <see cref="ScriptOptions"/> with the references changed. 250public ScriptOptions WithReferences(IEnumerable<Assembly> references) 254/// Creates a new <see cref="ScriptOptions"/> with the references changed. 258public ScriptOptions WithReferences(params Assembly[] references) 262/// Creates a new <see cref="ScriptOptions"/> with references added. 266public ScriptOptions AddReferences(IEnumerable<Assembly> references) 273/// Creates a new <see cref="ScriptOptions"/> with references added. 277public ScriptOptions AddReferences(params Assembly[] references) 281/// Creates a new <see cref="ScriptOptions"/> with the references changed. 284public ScriptOptions WithReferences(IEnumerable<string> references) 288/// Creates a new <see cref="ScriptOptions"/> with the references changed. 291public ScriptOptions WithReferences(params string[] references) 295/// Creates a new <see cref="ScriptOptions"/> with references added. 298public ScriptOptions AddReferences(IEnumerable<string> references) 302/// Creates a new <see cref="ScriptOptions"/> with references added. 304public ScriptOptions AddReferences(params string[] references) 308/// Creates a new <see cref="ScriptOptions"/> with specified <see cref="MetadataResolver"/>. 310public ScriptOptions WithMetadataResolver(MetadataReferenceResolver resolver) 314/// Creates a new <see cref="ScriptOptions"/> with specified <see cref="SourceResolver"/>. 316public ScriptOptions WithSourceResolver(SourceReferenceResolver resolver) 320/// Creates a new <see cref="ScriptOptions"/> with the <see cref="Imports"/> changed. 323private ScriptOptions WithImports(ImmutableArray<string> imports) 327/// Creates a new <see cref="ScriptOptions"/> with the <see cref="Imports"/> changed. 330public ScriptOptions WithImports(IEnumerable<string> imports) 334/// Creates a new <see cref="ScriptOptions"/> with the <see cref="Imports"/> changed. 337public ScriptOptions WithImports(params string[] imports) 341/// Creates a new <see cref="ScriptOptions"/> with <see cref="Imports"/> added. 344public ScriptOptions AddImports(IEnumerable<string> imports) 348/// Creates a new <see cref="ScriptOptions"/> with <see cref="Imports"/> added. 351public ScriptOptions AddImports(params string[] imports) 355/// Creates a new <see cref="ScriptOptions"/> with debugging information enabled. 357public ScriptOptions WithEmitDebugInformation(bool emitDebugInformation) 361/// Creates a new <see cref="ScriptOptions"/> with specified <see cref="FileEncoding"/>. 363public ScriptOptions WithFileEncoding(Encoding encoding) 367/// Create a new <see cref="ScriptOptions"/> with the specified <see cref="OptimizationLevel"/>. 369public ScriptOptions WithOptimizationLevel(OptimizationLevel optimizationLevel) 373/// Create a new <see cref="ScriptOptions"/> with unsafe code regions allowed. 375public ScriptOptions WithAllowUnsafe(bool allowUnsafe) 379/// Create a new <see cref="ScriptOptions"/> with bounds checking on integer arithmetic enforced. 381public ScriptOptions WithCheckOverflow(bool checkOverflow) 385/// Create a new <see cref="ScriptOptions"/> with the specific <see cref="WarningLevel"/>. 387public ScriptOptions WithWarningLevel(int warningLevel) 390internal ScriptOptions WithParseOptions(ParseOptions parseOptions) 393internal ScriptOptions WithCreateFromFileFunc(Func<string, PEStreamOptions, MetadataReferenceProperties, MetadataImageReference> createFromFileFunc)
ScriptState.cs (4)
142public Task<ScriptState<object>> ContinueWithAsync(string code, ScriptOptions options, CancellationToken cancellationToken) 156public Task<ScriptState<object>> ContinueWithAsync(string code, ScriptOptions options = null, Func<Exception, bool> catchException = null, CancellationToken cancellationToken = default(CancellationToken)) 166public Task<ScriptState<TResult>> ContinueWithAsync<TResult>(string code, ScriptOptions options, CancellationToken cancellationToken) 180public Task<ScriptState<TResult>> ContinueWithAsync<TResult>(string code, ScriptOptions options = null, Func<Exception, bool> catchException = null, CancellationToken cancellationToken = default(CancellationToken))
Microsoft.CodeAnalysis.Scripting.TestUtilities (7)
ScriptTaskExtensions.cs (5)
15public static async Task<ScriptState<object>> ContinueWith(this Task<ScriptState> task, string code, ScriptOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) 20public static async Task<ScriptState<object>> ContinueWith(this Task<ScriptState<object>> task, string code, ScriptOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) 25public static async Task<ScriptState<T>> ContinueWith<T>(this Task<ScriptState> task, string code, ScriptOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) 30public static async Task<ScriptState<T>> ContinueWith<T>(this Task<ScriptState<object>> task, string code, ScriptOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) 35public static async Task<ScriptState<object>> ContinueWith<S>(this Task<ScriptState<S>> task, string code, ScriptOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
ScriptTestBase.cs (2)
27public ScriptOptions ScriptOptions { get; } 37ScriptOptions = ScriptOptions.Default
Microsoft.CodeAnalysis.Scripting.UnitTests (51)
ScriptOptionsTests.cs (51)
25var options = ScriptOptions.Default. 40var options = ScriptOptions.Default.WithReferences(ImmutableArray<MetadataReference>.Empty); 63var empty = ScriptOptions.Default.WithReferences(ImmutableArray<MetadataReference>.Empty); 65var options = empty.WithReferences("System.Linq", "system.linq"); 82var options = ScriptOptions.Default.WithReferences(ImmutableArray<MetadataReference>.Empty); 106var options = ScriptOptions.Default. 120var options = ScriptOptions.Default; 141var options = ScriptOptions.Default; 162var scriptOptions = ScriptOptions.Default.WithImports(["System", "System.IO"]); 170Assert.True(ScriptOptions.Default.WithEmitDebugInformation(true).EmitDebugInformation); 171Assert.False(ScriptOptions.Default.WithEmitDebugInformation(false).EmitDebugInformation); 172Assert.False(ScriptOptions.Default.EmitDebugInformation); 178var options = ScriptOptions.Default.WithEmitDebugInformation(true); 185var options = ScriptOptions.Default.WithFileEncoding(Encoding.ASCII); 192var options = ScriptOptions.Default.WithFileEncoding(Encoding.ASCII); 199Assert.True(ScriptOptions.Default.WithAllowUnsafe(true).AllowUnsafe); 200Assert.False(ScriptOptions.Default.WithAllowUnsafe(false).AllowUnsafe); 201Assert.True(ScriptOptions.Default.AllowUnsafe); 209var options = ScriptOptions.Default.WithAllowUnsafe(allowUnsafe); 218var scriptOptions = ScriptOptions.Default.WithAllowUnsafe(allowUnsafe); 226Assert.True(ScriptOptions.Default.WithCheckOverflow(true).CheckOverflow); 227Assert.False(ScriptOptions.Default.WithCheckOverflow(false).CheckOverflow); 228Assert.False(ScriptOptions.Default.CheckOverflow); 236var options = ScriptOptions.Default.WithCheckOverflow(checkOverflow); 245var scriptOptions = ScriptOptions.Default.WithCheckOverflow(checkOverflow); 255Assert.Equal(ScriptOptions.Default.WithOptimizationLevel(optimizationLevel).OptimizationLevel, optimizationLevel); 256Assert.Equal(OptimizationLevel.Debug, ScriptOptions.Default.OptimizationLevel); 264var options = ScriptOptions.Default.WithOptimizationLevel(optimizationLevel); 273var scriptOptions = ScriptOptions.Default.WithOptimizationLevel(optimizationLevel); 286Assert.Equal(ScriptOptions.Default.WithWarningLevel(warningLevel).WarningLevel, warningLevel); 287Assert.Equal(4, ScriptOptions.Default.WarningLevel); 298var options = ScriptOptions.Default.WithWarningLevel(warningLevel); 310var scriptOptions = ScriptOptions.Default.WithWarningLevel(warningLevel);
Microsoft.CodeAnalysis.VisualBasic.Scripting (7)
Hosting\VisualBasicReplServiceProvider.vb (1)
38Public Overrides Function CreateScript(Of T)(code As String, options As ScriptOptions, globalsTypeOpt As Type, assemblyLoader As InteractiveAssemblyLoader) As Script(Of T)
VisualBasicScript.vb (6)
24Optional options As ScriptOptions = Nothing, 34Optional options As ScriptOptions = Nothing, 44Optional options As ScriptOptions = Nothing, 54Optional options As ScriptOptions = Nothing, 64Optional options As ScriptOptions = Nothing, 74Optional options As ScriptOptions = Nothing,
Microsoft.CodeAnalysis.VisualBasic.Scripting.UnitTests (2)
ScriptTests.vb (2)
26Private ReadOnly DefaultOptions As ScriptOptions = ScriptOptions.AddReferences(s_msvbReference) 77Assert.Empty(ScriptOptions.Default.Imports)