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