9 overrides of Encoding
Microsoft.CodeAnalysis (6)
Text\ChangedText.cs (1)
102public override Encoding? Encoding
Text\CompositeText.cs (1)
52public override Encoding? Encoding
Text\LargeText.cs (1)
152public override Encoding? Encoding => _encodingOpt;
Text\StringBuilderText.cs (1)
33public override Encoding? Encoding
Text\StringText.cs (1)
37public override Encoding? Encoding => _encodingOpt;
Text\SubText.cs (1)
37public override Encoding? Encoding => UnderlyingText.Encoding;
Microsoft.CodeAnalysis.CSharp.Features (1)
EmbeddedLanguages\CSharpTestEmbeddedLanguageClassifier.cs (1)
278public override Encoding? Encoding { get; }
Microsoft.CodeAnalysis.EditorFeatures.Text (1)
Extensions.SnapshotSourceText.cs (1)
106public override Encoding? Encoding
Microsoft.CodeAnalysis.Test.Utilities (1)
Syntax\SourceUtilities.cs (1)
27public override Encoding Encoding => Encoding.UTF8;
129 references to Encoding
Microsoft.Analyzers.Extra.Tests (1)
Resources\RoslynTestUtils.cs (1)
507return document.WithText(SourceText.From(newText.ToString(), newText.Encoding, newText.ChecksumAlgorithm));
Microsoft.Analyzers.Local.Tests (1)
Resources\RoslynTestUtils.cs (1)
508return document.WithText(SourceText.From(newText.ToString(), newText.Encoding, newText.ChecksumAlgorithm));
Microsoft.AspNetCore.Http.Extensions.Tests (1)
RequestDelegateGenerator\RequestDelegateCreationTestBase.cs (1)
137var encoding = text.Encoding ?? Encoding.UTF8;
Microsoft.AspNetCore.Http.Microbenchmarks (1)
src\Http\Http.Extensions\test\RequestDelegateGenerator\RequestDelegateCreationTestBase.cs (1)
137var encoding = text.Encoding ?? Encoding.UTF8;
Microsoft.CodeAnalysis (23)
Compilation\Compilation.cs (1)
2497if (!string.IsNullOrEmpty(tree.FilePath) && tree.GetText().Encoding == null)
Compilation\DeterministicKeyBuilder.cs (1)
280writer.Write("encodingName", sourceText.Encoding?.EncodingName);
EmbeddedText.cs (4)
297RoslynDebug.Assert(text.Encoding != null); 303maxByteCount = text.Encoding.GetMaxByteCount(text.Length); 319using (var writer = new StreamWriter(builder, text.Encoding, bufferSize: Math.Max(1, text.Length), leaveOpen: true)) 330using (var writer = new StreamWriter(deflater, text.Encoding, bufferSize: 1024, leaveOpen: true))
SourceGeneration\AdditionalSourcesCollection.cs (1)
81if (source.Encoding is null)
Text\ChangedText.cs (1)
104get { return _newText.Encoding; }
Text\CompositeText.cs (4)
194return SourceText.From(string.Empty, original.Encoding, original.ChecksumAlgorithm); 202return new CompositeText(segments.ToImmutable(), original.Encoding, original.ChecksumAlgorithm); 346var encoding = segments[i].Encoding; 402var encoding = segments[0].Encoding;
Text\SourceText.cs (6)
428/// Otherwise, <see cref="Encoding" /> must be non-null. 439return Encoding != null; 506return SourceText.From(string.Empty, this.Encoding, this.ChecksumAlgorithm); 578/// back to a <see cref="Stream"/> (using the provided <see cref="Encoding"/>), and computing the hash off of 589/// same checksum in <em>normal</em> scenarios. This is because the use of the <see cref="Encoding"/> can lead 804var segment = SourceText.From(change.NewText!, this.Encoding, this.ChecksumAlgorithm);
Text\SourceTextComparer.cs (2)
37var encodingHash = obj.Encoding != null ? obj.Encoding.GetHashCode() : 0;
Text\SourceTextStream.cs (2)
33Debug.Assert(source.Encoding != null || useDefaultEncodingIfNull); 36_encoding = source.Encoding ?? s_utf8EncodingWithNoBOM;
Text\SubText.cs (1)
37public override Encoding? Encoding => UnderlyingText.Encoding;
Microsoft.CodeAnalysis.CSharp (9)
Syntax\CSharpSyntaxTree.cs (2)
510text.Encoding, 577newText.Encoding,
Syntax\CSharpSyntaxTree.DebuggerSyntaxTree.cs (1)
19text.Encoding,
Syntax\CSharpSyntaxTree.LazySyntaxTree.cs (4)
57get { return _text.Encoding; } 118_text.Encoding, 139_text.Encoding, 171_text.Encoding,
Syntax\CSharpSyntaxTree.ParsedSyntaxTree.cs (2)
45Debug.Assert(textOpt == null || textOpt.Encoding == encodingOpt && textOpt.ChecksumAlgorithm == checksumAlgorithm); 48_encodingOpt = encodingOpt ?? textOpt?.Encoding;
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (2)
PdbSourceDocument\AbstractPdbSourceDocumentTests.cs (2)
285File.WriteAllText(sourceCodePaths[i], sources[i].ToString(), sources[i].Encoding); 317emitOptions = emitOptions.WithDefaultSourceFileEncoding(sources[0].Encoding);
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (7)
Syntax\Mocks\MockCSharpSyntaxTree.cs (1)
44=> _sourceText.Encoding;
Syntax\SyntaxFactoryTests.cs (2)
46Assert.Null(text.Encoding); 54Assert.Null(text.Encoding);
Syntax\SyntaxTreeTests.cs (4)
252Assert.Null(newText.Encoding); 269Assert.Same(Encoding.Unicode, newText.Encoding); 294Assert.Null(newText.Encoding); 310Assert.Same(Encoding.Unicode, newText.Encoding);
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (1)
Workspaces\TextFactoryTests.cs (1)
122Assert.Equal(expectedEncoding, text.Encoding);
Microsoft.CodeAnalysis.Features (2)
EditAndContinue\CommittedSolution.cs (2)
341return SourceText.From(text, sourceText.Encoding, checksumAlgorithm); 344return await Task.Run(() => TryGetPdbMatchingSourceTextFromDisk(filePath, sourceText.Encoding, requiredChecksum, checksumAlgorithm), cancellationToken).ConfigureAwait(false);
Microsoft.CodeAnalysis.LanguageServer (1)
HostWorkspace\Razor\RazorDynamicFileInfoProvider.TextChangesTextLoader.cs (1)
64if (sourceText.Encoding?.CodePage != _codePage)
Microsoft.CodeAnalysis.UnitTests (31)
Text\SourceTextTests.cs (16)
56Assert.Same(s_utf8, SourceText.From(HelloWorld, s_utf8).Encoding); 57Assert.Same(s_unicode, SourceText.From(HelloWorld, s_unicode).Encoding); 60Assert.Same(s_unicode, SourceText.From(bytes, bytes.Length, s_unicode).Encoding); 61Assert.Equal(utf8NoBOM, SourceText.From(bytes, bytes.Length, null).Encoding); 64Assert.Same(s_unicode, SourceText.From(stream, s_unicode).Encoding); 65Assert.Equal(utf8NoBOM, SourceText.From(stream, null).Encoding); 74Assert.Equal(utf8BOM, SourceText.From(bytes, bytes.Length, s_unicode).Encoding); 75Assert.Equal(utf8BOM, SourceText.From(bytes, bytes.Length, null).Encoding); 78Assert.Equal(utf8BOM, SourceText.From(stream, s_unicode).Encoding); 79Assert.Equal(utf8BOM, SourceText.From(stream, null).Encoding); 360Assert.Same(s_utf8, SourceText.From(actual, expected.Length, s_utf8).Encoding); 361Assert.Same(s_unicode, SourceText.From(actual, expected.Length, s_unicode).Encoding); 362Assert.Null(SourceText.From(actual, expected.Length, null).Encoding); 379Assert.Same(s_utf8, SourceText.From(actual, expected.Length, s_utf8).Encoding); 380Assert.Same(s_unicode, SourceText.From(actual, expected.Length, s_unicode).Encoding); 381Assert.Null(SourceText.From(actual, expected.Length, null).Encoding);
Text\StringTextDecodingTests.cs (10)
61Assert.Equal(932, data.Encoding?.WindowsCodePage); 71Assert.Equal(932, data.Encoding?.WindowsCodePage); 174Assert.Equal(1252, sourceText.Encoding.CodePage); 175Assert.NotNull(sourceText.Encoding.GetEncoder()); 176Assert.NotNull(sourceText.Encoding.GetDecoder()); 177Assert.Equal(2, sourceText.Encoding.GetMaxByteCount(1)); 178Assert.Equal(1, sourceText.Encoding.GetMaxCharCount(1)); 179Assert.Equal(text, sourceText.Encoding.GetString(bytes)); 197Assert.Equal(Encoding.UTF8.EncodingName, sourceText.Encoding.EncodingName); 311Assert.Equal(encoding.CodePage, encodedText.Encoding.CodePage);
Text\StringTextTest.cs (1)
55Assert.Null(data.Encoding);
Text\TextChangeTests.cs (4)
198Assert.Same(Encoding.Unicode, subText.Encoding); 241Assert.Same(Encoding.Unicode, newText.Encoding); 578var writer = new LargeTextWriter(largeText.Encoding, largeText.ChecksumAlgorithm, 10); 615var writer = new LargeTextWriter(largeText.Encoding, largeText.ChecksumAlgorithm, chunk1.Length * 4);
Microsoft.CodeAnalysis.VisualBasic (9)
Syntax\VisualBasicSyntaxTree.DebuggerSyntaxTree.vb (1)
18text.Encoding,
Syntax\VisualBasicSyntaxTree.LazySyntaxTree.vb (4)
62Return _text.Encoding 121_text.Encoding, 140_text.Encoding, 166_text.Encoding,
Syntax\VisualBasicSyntaxTree.ParsedSyntaxTree.vb (2)
48Debug.Assert(textOpt Is Nothing OrElse textOpt.Encoding Is encodingOpt AndAlso textOpt.ChecksumAlgorithm = checksumAlgorithm) 52_encodingOpt = If(encodingOpt, textOpt?.Encoding)
Syntax\VisualBasicSyntaxTree.vb (2)
137newText.Encoding, 299text.Encoding,
Microsoft.CodeAnalysis.VisualBasic.EditorFeatures (1)
NavigationBar\VisualBasicEditorNavigationBarItemService_CodeGeneration.vb (1)
34Dim navigationPoint = NavigationPointHelpers.GetNavigationPoint(generatedTree.GetText(text.Encoding), indentSize, generatedNode)
Microsoft.CodeAnalysis.VisualBasic.Syntax.UnitTests (6)
Syntax\SyntaxFactoryTests.vb (2)
15Assert.Null(text.Encoding) 22Assert.Null(text.Encoding)
Syntax\SyntaxTreeTests.vb (4)
119Assert.Null(newText.Encoding) 136Assert.Same(Encoding.Unicode, newText.Encoding) 159Assert.Null(newText.Encoding) 173Assert.Same(Encoding.Unicode, newText.Encoding)
Microsoft.CodeAnalysis.Workspaces (4)
Serialization\SerializableSourceText.cs (1)
165writer.WriteEncoding(_text.Encoding);
SourceGeneration\IRemoteSourceGenerationService.cs (1)
77/// <param name="EncodingName">Result of <see cref="SourceText.Encoding"/>'s <see cref="Encoding.WebName"/>.</param>
TemporaryStorage\TemporaryStorageService.cs (1)
106return new(this, memoryMappedInfo.MemoryMappedFile, identifier, text.ChecksumAlgorithm, text.Encoding, text.GetContentHash());
Workspace\Solution\SourceGeneratedDocumentState.cs (1)
128=> new(this.GetOriginalSourceTextContentHash(), this.SourceText.Encoding?.WebName, this.SourceText.ChecksumAlgorithm);
Microsoft.CodeAnalysis.Workspaces.MSBuild (4)
MSBuild\MSBuildWorkspace.cs (4)
423if (text.Encoding != null) 425return text.Encoding; 472.WithTextLoader(new WorkspaceFileTextLoader(Services.SolutionServices, fullPath, text.Encoding)); 483this.SaveDocumentText(info.Id, fullPath, text, text.Encoding ?? Encoding.UTF8);
Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests (10)
VisualStudioMSBuildWorkspaceTests.cs (10)
2795Assert.Equal(new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true), text.Encoding); 2814Assert.Equal(new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true), text.Encoding); 2833Assert.Equal(new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true), text.Encoding); 2886Assert.Null(doc2text.Encoding); 2889Assert.Null(doc2tree.GetText().Encoding); 2893Assert.Equal(encoding.EncodingName, text.Encoding.EncodingName); 2899Assert.Null(doc3text.Encoding); 2902Assert.Null(doc3tree.GetText().Encoding); 2908Assert.Null(noEncodingDocText.Encoding); 3309Assert.Equal(Encoding.GetEncoding(1254), text.Encoding);
Microsoft.CodeAnalysis.Workspaces.UnitTests (4)
SolutionTests\SolutionTests.cs (2)
3993Assert.Equal(Encoding.UTF32, doc.GetTextAsync().Result.Encoding); 4000Assert.Equal(Encoding.UTF32, newDoc.GetTextAsync().Result.Encoding);
UtilityTest\SourceTextSerializationTests.cs (1)
44var recovered = SourceTextExtensions.ReadFrom(textService, reader, originalText.Encoding, originalText.ChecksumAlgorithm, CancellationToken.None);
WorkspaceServiceTests\TemporaryStorageServiceTests.cs (1)
84Assert.Equal(text.Encoding, text2.Encoding);
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.Unit.Tests (1)
test\Generators\Shared\RoslynTestUtils.cs (1)
549return document.WithText(SourceText.From(newText.ToString(), newText.Encoding, newText.ChecksumAlgorithm));
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.VisualStudio.LanguageServices (4)
Implementation\AbstractEditorFactory.cs (1)
374using var textWriter = new StreamWriter(filePath, append: false, encoding: formattedText.Encoding);
ProjectSystem\VisualStudioWorkspaceImpl.cs (2)
948using var writer = new StreamWriter(documentInfo.FilePath, append: false, encoding: text.Encoding ?? Encoding.UTF8); 992using var writer = new StreamWriter(filePath, append: false, encoding: initialText.Encoding ?? Encoding.UTF8);
Workspace\SourceGeneratedFileManager.cs (1)
386textDocument.Encoding = generatedSource.Encoding;
Roslyn.VisualStudio.Next.UnitTests (2)
Services\ServiceHubServicesTests.cs (2)
490Assert.Equal(localText.Encoding, remoteText.Encoding);