114 references to From
ConfigurationSchemaGenerator.Tests (2)
GeneratorTests.cs (2)
30private static readonly SyntaxTree s_implicitUsingsSyntaxTree = SyntaxFactory.ParseSyntaxTree(SourceText.From( 1561var sourceSyntaxTree = SyntaxFactory.ParseSyntaxTree(SourceText.From(sourceText));
dotnet-format (1)
Formatters\CharsetFormatter.cs (1)
40return SourceText.From(sourceText.ToString(), encoding, sourceText.ChecksumAlgorithm);
EventSourceGenerator (1)
EventSourceGenerator.Emitter.cs (1)
33context.AddSource($"{ec.ClassName}.g.cs", SourceText.From(sb.ToString(), Encoding.UTF8));
GenerateDocumentationAndConfigFiles (1)
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\Extensions\AdditionalTextExtensions.cs (1)
15private static readonly SourceText s_emptySourceText = SourceText.From("", s_utf8bom, SourceHashAlgorithm.Sha256);
Microsoft.Analyzers.Extra.Tests (2)
Resources\FileVisibleToAnalyzer.cs (1)
26public override SourceText? GetText(CancellationToken cancellationToken = default) => SourceText.From(File.ReadAllText(Path));
Resources\RoslynTestUtils.cs (1)
507return document.WithText(SourceText.From(newText.ToString(), newText.Encoding, newText.ChecksumAlgorithm));
Microsoft.Analyzers.Local.Tests (2)
Resources\FileVisibleToAnalyzer.cs (1)
26public override SourceText? GetText(CancellationToken cancellationToken = default) => SourceText.From(File.ReadAllText(Path));
Resources\RoslynTestUtils.cs (1)
508return document.WithText(SourceText.From(newText.ToString(), newText.Encoding, newText.ChecksumAlgorithm));
Microsoft.AspNetCore.App.Analyzers (1)
Infrastructure\VirtualChars\CSharpVirtualCharService.cs (1)
204var tokenSourceText = SourceText.From(token.Text);
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation (1)
RuntimeViewCompiler.cs (1)
374var sourceText = SourceText.From(compilationContent, Encoding.UTF8);
Microsoft.AspNetCore.SignalR.Client.SourceGenerator (4)
HubClientProxyGenerator.Emitter.cs (2)
123_context.AddSource("HubClientProxy.g.cs", SourceText.From(extensions.ToString(), Encoding.UTF8)); 192_context.AddSource($"HubClientProxy.{typeSpec.TypeName}.g.cs", SourceText.From(registrationMethodBody.ToString(), Encoding.UTF8));
HubServerProxyGenerator.Emitter.cs (2)
75_context.AddSource("HubServerProxy.g.cs", SourceText.From(getProxy.ToString(), Encoding.UTF8)); 163_context.AddSource($"HubServerProxy.{classSpec.ClassTypeName}.g.cs", SourceText.From(proxy.ToString(), Encoding.UTF8));
Microsoft.CodeAnalysis (14)
CommandLine\AnalyzerConfig.cs (1)
180return Parse(SourceText.From(text), pathToFile);
SourceGeneration\GeneratorContexts.cs (2)
85public void AddSource(string hintName, string source) => AddSource(hintName, SourceText.From(source, Encoding.UTF8, checksumAlgorithm: _checksumAlgorithm == SourceHashAlgorithm.None ? SourceHashAlgorithms.Default : _checksumAlgorithm)); 277public void AddSource(string hintName, string source) => AddSource(hintName, SourceText.From(source, Encoding.UTF8));
SourceGeneration\IncrementalContexts.cs (4)
243public void AddSource(string hintName, string source) => AddSource(hintName, SourceText.From(source, Encoding.UTF8)); 263public void AddEmbeddedAttributeDefinition() => AddSource("Microsoft.CodeAnalysis.EmbeddedAttribute", SourceText.From(_embeddedAttributeDefinition, encoding: Encoding.UTF8)); 292public void AddSource(string hintName, string source) => AddSource(hintName, SourceText.From(source, Encoding.UTF8, checksumAlgorithm: ChecksumAlgorithm == SourceHashAlgorithm.None ? SourceHashAlgorithms.Default : ChecksumAlgorithm)); 351public void AddSource(string hintName, string source) => AddSource(hintName, SourceText.From(source, Encoding.UTF8, checksumAlgorithm: ChecksumAlgorithm == SourceHashAlgorithm.None ? SourceHashAlgorithms.Default : ChecksumAlgorithm));
Text\CompositeText.cs (2)
194return SourceText.From(string.Empty, original.Encoding, original.ChecksumAlgorithm); 223segments.Insert(i, SourceText.From("\r\n"));
Text\LargeText.cs (2)
62return SourceText.From(string.Empty, encoding, checksumAlgorithm); 85return SourceText.From(string.Empty, encodingOpt, checksumAlgorithm);
Text\SourceText.cs (3)
151return From(text, encoding, checksumAlgorithm); 508return SourceText.From(string.Empty, this.Encoding, this.ChecksumAlgorithm); 823var segment = SourceText.From(change.NewText!, this.Encoding, this.ChecksumAlgorithm);
Microsoft.CodeAnalysis.Analyzers (1)
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\Extensions\AdditionalTextExtensions.cs (1)
15private static readonly SourceText s_emptySourceText = SourceText.From("", s_utf8bom, SourceHashAlgorithm.Sha256);
Microsoft.CodeAnalysis.AnalyzerUtilities (1)
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\Extensions\AdditionalTextExtensions.cs (1)
15private static readonly SourceText s_emptySourceText = SourceText.From("", s_utf8bom, SourceHashAlgorithm.Sha256);
Microsoft.CodeAnalysis.CodeStyle (2)
src\roslyn\src\Analyzers\Core\Analyzers\Formatting\AbstractFormattingAnalyzer.cs (2)
72if (oldText.GetSubText(new TextSpan(change.Span.Start + offset, change.NewText.Length)).ContentEquals(SourceText.From(change.NewText))) 81if (oldText.GetSubText(new TextSpan(change.Span.Start, change.NewText.Length)).ContentEquals(SourceText.From(change.NewText)))
Microsoft.CodeAnalysis.CSharp (11)
Parser\LanguageParser_InterpolatedString.cs (3)
167using var tempLexer = new Lexer(SourceText.From(originalText), this.Options, allowPreprocessorDirectives: false); 501using var tempLexer = new Lexer(SourceText.From(expressionText), options, allowPreprocessorDirectives: false, interpolationFollowedByColon: interpolation.HasColon); 592using var tempLexer = new Lexer(SourceText.From(fakeString), this.Options, allowPreprocessorDirectives: false);
Syntax\CSharpSyntaxTree.cs (2)
459return ParseText(SourceText.From(text, encoding, SourceHashAlgorithm.Sha1), options, path, diagnosticOptions, isGeneratedCode, cancellationToken); 920=> ParseText(SourceText.From(text, encoding, SourceHashAlgorithm.Sha1), options, path, diagnosticOptions, isGeneratedCode: null, cancellationToken);
Syntax\CSharpSyntaxTree.Dummy.cs (2)
35return SourceText.From(string.Empty, Encoding, ChecksumAlgorithm); 40text = SourceText.From(string.Empty, Encoding, ChecksumAlgorithm);
Syntax\SyntaxFactory.cs (4)
1591return CSharpSyntaxTree.ParseText(SourceText.From(text, encoding, SourceHashAlgorithm.Sha1), (CSharpParseOptions?)options, path, diagnosticOptions: null, isGeneratedCode: null, cancellationToken); 1952return SourceText.From(text, Encoding.UTF8).GetSubText(offset); 2838return ParseSyntaxTree(SourceText.From(text, encoding), options, path, diagnosticOptions, isGeneratedCode: null, cancellationToken); 2866return ParseSyntaxTree(SourceText.From(text, encoding), options, path, diagnosticOptions, isGeneratedCode, cancellationToken);
Microsoft.CodeAnalysis.CSharp.CodeStyle (1)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\EmbeddedLanguages\VirtualChars\CSharpVirtualCharService.cs (1)
191var tokenSourceText = SourceText.From(token.Text);
Microsoft.CodeAnalysis.CSharp.Scripting (1)
CSharpScript.cs (1)
37return Script.CreateInitialScript<T>(CSharpScriptCompiler.Instance, SourceText.From(code, options?.FileEncoding, SourceHashAlgorithms.Default), options, globalsType, assemblyLoader);
Microsoft.CodeAnalysis.CSharp.Workspaces (1)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\EmbeddedLanguages\VirtualChars\CSharpVirtualCharService.cs (1)
191var tokenSourceText = SourceText.From(token.Text);
Microsoft.CodeAnalysis.Features (7)
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.AbstractGlobalSuppressMessageCodeAction.cs (1)
109var emptyText = SourceText.From("", Encoding.UTF8, SourceHashAlgorithms.Default);
EditAndContinue\AbstractEditAndContinueAnalyzer.cs (1)
505private static readonly SourceText s_emptySource = SourceText.From("");
EditAndContinue\CommittedSolution.cs (1)
398return SourceText.From(text, defaultEncoding, checksumAlgorithm);
MetadataAsSource\DecompilationMetadataAsSourceFileProvider.cs (2)
353var assemblyInfoSourceText = SourceText.From(assemblyInfoString, MetadataAsSourceGeneratedFileInfo.Encoding, MetadataAsSourceGeneratedFileInfo.ChecksumAlgorithm); 363var emptySourceText = SourceText.From(string.Empty, MetadataAsSourceGeneratedFileInfo.Encoding, MetadataAsSourceGeneratedFileInfo.ChecksumAlgorithm);
src\roslyn\src\Analyzers\Core\Analyzers\Formatting\AbstractFormattingAnalyzer.cs (2)
72if (oldText.GetSubText(new TextSpan(change.Span.Start + offset, change.NewText.Length)).ContentEquals(SourceText.From(change.NewText))) 81if (oldText.GetSubText(new TextSpan(change.Span.Start, change.NewText.Length)).ContentEquals(SourceText.From(change.NewText)))
Microsoft.CodeAnalysis.Razor.Compiler (4)
CSharp\DefaultUtf8WriteLiteralFeature.cs (1)
183var probeText = SourceText.From(sb.ToString());
Language\Legacy\SeekableTextReader.cs (1)
19public SeekableTextReader(string source, string filePath) : this(SourceText.From(source, checksumAlgorithm: SourceHashAlgorithm.Sha256), filePath)
Language\RazorSourceDocument.cs (2)
218var sourceText = SourceText.From(content, encoding, checksumAlgorithm: SourceHashAlgorithm.Sha256); 246var sourceText = SourceText.From(content, encoding, checksumAlgorithm: SourceHashAlgorithm.Sha256);
Microsoft.CodeAnalysis.ResxSourceGenerator (5)
AbstractResxGenerator.cs (4)
252var errorText = SourceText.From(text, Encoding.UTF8, SourceHashAlgorithm.Sha256); 366OutputText = SourceText.From("", Encoding.UTF8); 392OutputText = SourceText.From(result, Encoding.UTF8, SourceHashAlgorithm.Sha256); 735OutputText = SourceText.From(result, Encoding.UTF8, SourceHashAlgorithm.Sha256);
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\Extensions\AdditionalTextExtensions.cs (1)
15private static readonly SourceText s_emptySourceText = SourceText.From("", s_utf8bom, SourceHashAlgorithm.Sha256);
Microsoft.CodeAnalysis.Scripting (4)
Hosting\CommandLine\CommandLineRunner.cs (3)
231var script = Script.CreateInitialScript<object>(_scriptCompiler, SourceText.From(initialScriptCodeOpt), options, globals.GetType(), assemblyLoaderOpt: null); 258var tree = _scriptCompiler.ParseSubmission(SourceText.From(input.ToString()), options.ParseOptions, cancellationToken); 283newScript = Script.CreateInitialScript<object>(_scriptCompiler, SourceText.From(code ?? string.Empty), options, globals.GetType(), assemblyLoaderOpt: null);
Script.cs (1)
117return new Script<TResult>(Compiler, Builder, SourceText.From(code ?? "", options.FileEncoding), options, GlobalsType, this);
Microsoft.CodeAnalysis.TestAnalyzerReference (4)
HelloWorldGenerator.cs (3)
27context.AddSource(GeneratedEnglishClassName, SourceText.From($$""" 38context.AddSource(GeneratedSpanishClassName, SourceText.From($$""" 48context.AddSource(GeneratedEnglishClassName + "WithTime", SourceText.From($$"""
NonSourceFileRefactoring.cs (1)
28var newText = SourceText.From(text.ToString() + Environment.NewLine + "# Refactored");
Microsoft.CodeAnalysis.VisualBasic (8)
Binding\Binder_Expressions.vb (1)
1102Dim tree = VisualBasicSyntaxTree.ParseText(SourceText.From(codeToParse))
OptionsValidator.vb (1)
30Dim tree = VisualBasicSyntaxTree.ParseText(SourceText.From(importFileText), VisualBasicParseOptions.Default, "")
Syntax\SyntaxNodeFactories.vb (3)
50Return ParseSyntaxTree(SourceText.From(text, encoding, SourceHashAlgorithm.Sha1), options, path, cancellationToken) 79Return ParseSyntaxTree(SourceText.From(text, encoding), options, path, diagnosticOptions, cancellationToken) 288Return SourceText.From(text, Encoding.UTF8).GetSubText(offset)
Syntax\VisualBasicSyntaxTree.DummySyntaxTree.vb (2)
29Return SourceText.From(String.Empty, Me.Encoding, ChecksumAlgorithm) 33text = SourceText.From(String.Empty, Me.Encoding, ChecksumAlgorithm)
Syntax\VisualBasicSyntaxTree.vb (1)
255SourceText.From(text, encoding),
Microsoft.CodeAnalysis.VisualBasic.Scripting (1)
VisualBasicScript.vb (1)
26Return Script.CreateInitialScript(Of T)(VisualBasicScriptCompiler.Instance, SourceText.From(If(code, String.Empty)), options, globalsType, assemblyLoader)
Microsoft.CodeAnalysis.Workspaces (7)
Workspace\Host\TextFactory\TextFactoryService.cs (1)
37: SourceText.From(reader.ReadToEnd(), encoding, checksumAlgorithm);
Workspace\Solution\Solution.cs (3)
986var sourceText = SourceText.From(text, encoding: null, checksumAlgorithm: project.ChecksumAlgorithm); 1028var sourceText = SourceText.From(string.Empty, encoding: null, project.ChecksumAlgorithm); 1089=> this.AddAdditionalDocument(documentId, name, SourceText.From(text), folders, filePath);
Workspace\Solution\SolutionCompilationState.RegularCompilationTracker_Generators.cs (1)
233var sourceText = SourceText.From(
Workspace\Solution\TextDocumentState.cs (1)
159: CreateStrongText(TextAndVersion.Create(SourceText.From(string.Empty, encoding: null, loadTextOptions.ChecksumAlgorithm), VersionStamp.Default, filePath));
Workspace\Solution\TextLoader.cs (1)
161SourceText.From(string.Empty, Encoding.UTF8),
Microsoft.Diagnostics.DataContractReader.DataGenerator (3)
CdacGenerator.cs (3)
48SourceText.From(LayoutSetSource.Source, Encoding.UTF8)); 55SourceText.From(TypeNameResolverSource.Source, Encoding.UTF8)); 68spc.AddSource(Emitter.HintNameFor(model), SourceText.From(Emitter.Emit(model), Encoding.UTF8)));
Microsoft.Extensions.Logging.Generators (1)
LoggerMessageGenerator.Roslyn4.0.cs (1)
213context.AddSource("LoggerMessage.g.cs", SourceText.From(result, Encoding.UTF8));
Microsoft.Extensions.Options.SourceGeneration (1)
Generator.cs (1)
56context.AddSource("Validators.g.cs", SourceText.From(result, Encoding.UTF8));
Microsoft.Gen.BuildMetadata (1)
BuildMetadataGenerator.cs (1)
55context.AddSource("BuildMetadataExtensions.g.cs", SourceText.From(result, Encoding.UTF8));
Microsoft.Gen.BuildMetadata.Unit.Tests (1)
test\Generators\Shared\RoslynTestUtils.cs (1)
549return document.WithText(SourceText.From(newText.ToString(), newText.Encoding, newText.ChecksumAlgorithm));
Microsoft.Gen.ComplianceReports.Unit.Tests (1)
test\Generators\Shared\RoslynTestUtils.cs (1)
549return document.WithText(SourceText.From(newText.ToString(), newText.Encoding, newText.ChecksumAlgorithm));
Microsoft.Gen.ContextualOptions.Unit.Tests (1)
test\Generators\Shared\RoslynTestUtils.cs (1)
549return document.WithText(SourceText.From(newText.ToString(), newText.Encoding, newText.ChecksumAlgorithm));
Microsoft.Gen.Logging (1)
LoggingGenerator.cs (1)
49context.AddSource("Logging.g.cs", SourceText.From(result, Encoding.UTF8));
Microsoft.Gen.Logging.Unit.Tests (1)
test\Generators\Shared\RoslynTestUtils.cs (1)
549return document.WithText(SourceText.From(newText.ToString(), newText.Encoding, newText.ChecksumAlgorithm));
Microsoft.Gen.MetadataExtractor.Unit.Tests (1)
test\Generators\Shared\RoslynTestUtils.cs (1)
549return document.WithText(SourceText.From(newText.ToString(), newText.Encoding, newText.ChecksumAlgorithm));
Microsoft.Gen.Metrics (2)
MetricsGenerator.cs (2)
41context.AddSource("Factory.g.cs", SourceText.From(factory, Encoding.UTF8)); 45context.AddSource("Metrics.g.cs", SourceText.From(metrics, Encoding.UTF8));
Microsoft.Gen.Metrics.Unit.Tests (1)
test\Generators\Shared\RoslynTestUtils.cs (1)
549return document.WithText(SourceText.From(newText.ToString(), newText.Encoding, newText.ChecksumAlgorithm));
Microsoft.Gen.MetricsReports.Unit.Tests (1)
test\Generators\Shared\RoslynTestUtils.cs (1)
549return document.WithText(SourceText.From(newText.ToString(), newText.Encoding, newText.ChecksumAlgorithm));
Microsoft.Maui.Controls.SourceGen (3)
CodeBehindGenerator.cs (3)
295 context.AddSource(hintName, SourceText.From(sb.ToString(), Encoding.UTF8)); 377 context.AddSource(hintName, SourceText.From(sb.ToString(), Encoding.UTF8)); 640 sourceProductionContext.AddSource(hintName, SourceText.From(sb.ToString(), Encoding.UTF8));
Microsoft.ML.AutoML.SourceGenerator (3)
EstimatorTypeGenerator.cs (1)
53context.AddSource(className + ".cs", SourceText.From(code.TransformText(), Encoding.UTF8));
SweepableEstimatorFactoryGenerator.cs (1)
48context.AddSource(className + ".cs", SourceText.From(code.TransformText(), Encoding.UTF8));
SweepableEstimatorGenerator.cs (1)
73context.AddSource(c.Item1 + ".cs", SourceText.From(c.Item2, Encoding.UTF8));
Roslyn.Diagnostics.Analyzers (1)
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\Extensions\AdditionalTextExtensions.cs (1)
15private static readonly SourceText s_emptySourceText = SourceText.From("", s_utf8bom, SourceHashAlgorithm.Sha256);
Roslyn.Diagnostics.CSharp.Analyzers (1)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\EmbeddedLanguages\VirtualChars\CSharpVirtualCharService.cs (1)
191var tokenSourceText = SourceText.From(token.Text);
SuperFileCheck (1)
Program.cs (1)
265var syntaxTree = CSharpSyntaxTree.ParseText(SourceText.From(File.ReadAllText(filePath)));
System.Private.CoreLib.Generators (1)
NativeRuntimeEventSourceGenerator.cs (1)
56spc.AddSource($"{className}.g.cs", SourceText.From(source, System.Text.Encoding.UTF8));
System.Text.Json.SourceGeneration (1)
src\runtime\src\libraries\Common\src\SourceGenerators\SourceWriter.cs (1)
67return SourceText.From(_sb.ToString(), Encoding.UTF8);