523 references to SourceHashAlgorithm
GenerateDocumentationAndConfigFiles (9)
src\Compilers\Core\Portable\EncodedStringText.cs (8)
54/// from <see cref="SourceText.From(Stream, Encoding, SourceHashAlgorithm, bool)"/> in two ways: 74SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1, 87SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1, 130SourceHashAlgorithm checksumAlgorithm, 230internal static SourceText Create(Stream stream, Lazy<Encoding> getEncoding, Encoding defaultEncoding, SourceHashAlgorithm checksumAlgorithm, bool canBeEmbedded) 233internal static SourceText Decode(Stream data, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded)
src\RoslynAnalyzers\Utilities\Compiler\Extensions\AdditionalTextExtensions.cs (1)
15private static readonly SourceText s_emptySourceText = SourceText.From("", s_utf8bom, SourceHashAlgorithm.Sha256);
Metrics (9)
src\Compilers\Core\Portable\EncodedStringText.cs (8)
54/// from <see cref="SourceText.From(Stream, Encoding, SourceHashAlgorithm, bool)"/> in two ways: 74SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1, 87SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1, 130SourceHashAlgorithm checksumAlgorithm, 230internal static SourceText Create(Stream stream, Lazy<Encoding> getEncoding, Encoding defaultEncoding, SourceHashAlgorithm checksumAlgorithm, bool canBeEmbedded) 233internal static SourceText Decode(Stream data, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded)
src\RoslynAnalyzers\Utilities\Compiler\Extensions\AdditionalTextExtensions.cs (1)
15private static readonly SourceText s_emptySourceText = SourceText.From("", s_utf8bom, SourceHashAlgorithm.Sha256);
Metrics.Legacy (9)
src\Compilers\Core\Portable\EncodedStringText.cs (8)
54/// from <see cref="SourceText.From(Stream, Encoding, SourceHashAlgorithm, bool)"/> in two ways: 74SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1, 87SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1, 130SourceHashAlgorithm checksumAlgorithm, 230internal static SourceText Create(Stream stream, Lazy<Encoding> getEncoding, Encoding defaultEncoding, SourceHashAlgorithm checksumAlgorithm, bool canBeEmbedded) 233internal static SourceText Decode(Stream data, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded)
src\RoslynAnalyzers\Utilities\Compiler\Extensions\AdditionalTextExtensions.cs (1)
15private static readonly SourceText s_emptySourceText = SourceText.From("", s_utf8bom, SourceHashAlgorithm.Sha256);
Microsoft.CodeAnalysis (103)
CommandLine\CommandLineArguments.cs (1)
254public SourceHashAlgorithm ChecksumAlgorithm { get; internal set; }
CommandLine\CommandLineParser.cs (4)
1276internal static SourceHashAlgorithm TryParseHashAlgorithmName(string arg) 1280return SourceHashAlgorithm.Sha1; 1285return SourceHashAlgorithm.Sha256; 1290return SourceHashAlgorithm.None;
CommandLine\CommonCompiler.cs (1)
865private protected abstract GeneratorDriver CreateGeneratorDriver(string baseDirectory, ParseOptions parseOptions, ImmutableArray<ISourceGenerator> generators, AnalyzerConfigOptionsProvider analyzerConfigOptionsProvider, ImmutableArray<AdditionalText> additionalTexts, SourceHashAlgorithm checksumAlgorithm);
Compilation\DeterministicKeyBuilder.cs (1)
333var checksumAlgorithm = SourceHashAlgorithms.Default;
CryptographicHashProvider.cs (12)
65internal static int GetHashSize(SourceHashAlgorithm algorithmId) 69case SourceHashAlgorithm.Sha1: 72case SourceHashAlgorithm.Sha256: 80internal static HashAlgorithm? TryGetAlgorithm(SourceHashAlgorithm algorithmId) 84case SourceHashAlgorithm.Sha1: 88case SourceHashAlgorithm.Sha256: 96internal static HashAlgorithmName GetAlgorithmName(SourceHashAlgorithm algorithmId) 100case SourceHashAlgorithm.Sha1: 104case SourceHashAlgorithm.Sha256: 216internal static ImmutableArray<byte> ComputeSourceHash(ImmutableArray<byte> bytes, SourceHashAlgorithm hashAlgorithm = SourceHashAlgorithms.Default) 228internal static ImmutableArray<byte> ComputeSourceHash(ImmutableArray<ConstantValue> constants, SourceHashAlgorithm hashAlgorithm = SourceHashAlgorithms.Default) 282internal static ImmutableArray<byte> ComputeSourceHash(IEnumerable<Blob> bytes, SourceHashAlgorithm hashAlgorithm = SourceHashAlgorithms.Default)
EmbeddedText.cs (6)
44public SourceHashAlgorithm ChecksumAlgorithm { get; } 52private EmbeddedText(string filePath, ImmutableArray<byte> checksum, SourceHashAlgorithm checksumAlgorithm, ImmutableArray<byte> blob) 136public static EmbeddedText FromStream(string filePath, Stream stream, SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1) 175public static EmbeddedText FromBytes(string filePath, ArraySegment<byte> bytes, SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1)
EncodedStringText.cs (8)
54/// from <see cref="SourceText.From(Stream, Encoding, SourceHashAlgorithm, bool)"/> in two ways: 74SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1, 87SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1, 130SourceHashAlgorithm checksumAlgorithm, 230internal static SourceText Create(Stream stream, Lazy<Encoding> getEncoding, Encoding defaultEncoding, SourceHashAlgorithm checksumAlgorithm, bool canBeEmbedded) 233internal static SourceText Decode(Stream data, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded)
PEWriter\DebugSourceInfo.cs (1)
34SourceHashAlgorithm checksumAlgorithm,
SourceGeneration\GeneratorAdaptor.cs (1)
88public GeneratorExecutionContext ToExecutionContext(string sourceExtension, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken)
SourceGeneration\GeneratorContexts.cs (3)
24private readonly SourceHashAlgorithm _checksumAlgorithm; 26internal GeneratorExecutionContext(Compilation compilation, ParseOptions parseOptions, ImmutableArray<AdditionalText> additionalTexts, AnalyzerConfigOptionsProvider optionsProvider, ISyntaxContextReceiver? syntaxReceiver, string sourceExtension, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken = default) 85public void AddSource(string hintName, string source) => AddSource(hintName, SourceText.From(source, Encoding.UTF8, checksumAlgorithm: _checksumAlgorithm == SourceHashAlgorithm.None ? SourceHashAlgorithms.Default : _checksumAlgorithm));
SourceGeneration\GeneratorDriverOptions.cs (1)
29internal SourceHashAlgorithm ChecksumAlgorithm { get; init; }
SourceGeneration\GeneratorDriverState.cs (1)
84internal SourceHashAlgorithm ChecksumAlgorithm => _driverOptions.ChecksumAlgorithm;
SourceGeneration\IncrementalContexts.cs (3)
236internal readonly SourceHashAlgorithm ChecksumAlgorithm; 238internal SourceProductionContext(AdditionalSourcesCollection sources, DiagnosticBag diagnostics, Compilation compilation, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken) 254public void AddSource(string hintName, string source) => AddSource(hintName, SourceText.From(source, Encoding.UTF8, checksumAlgorithm: ChecksumAlgorithm == SourceHashAlgorithm.None ? SourceHashAlgorithms.Default : ChecksumAlgorithm));
Syntax\SyntaxNode.cs (2)
327public SourceText GetText(Encoding? encoding = null, SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1)
Syntax\SyntaxTree.cs (2)
31private SourceHashAlgorithm _lazyHashAlgorithm; 381Debug.Assert(_lazyHashAlgorithm != default(SourceHashAlgorithm));
Text\CompositeText.cs (3)
28private CompositeText(ImmutableArray<SourceText> segments, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm) 347var algorithm = segments[i].ChecksumAlgorithm; 403var algorithm = segments[0].ChecksumAlgorithm;
Text\LargeText.cs (4)
33internal LargeText(ImmutableArray<char[]> chunks, Encoding? encodingOpt, ImmutableArray<byte> checksum, SourceHashAlgorithm checksumAlgorithm, ImmutableArray<byte> embeddedTextBlob) 50internal LargeText(ImmutableArray<char[]> chunks, Encoding? encodingOpt, SourceHashAlgorithm checksumAlgorithm) 55internal static SourceText Decode(Stream stream, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded) 81internal static SourceText Decode(TextReader reader, int length, Encoding? encodingOpt, SourceHashAlgorithm checksumAlgorithm)
Text\LargeTextWriter.cs (2)
15private readonly SourceHashAlgorithm _checksumAlgorithm; 22public LargeTextWriter(Encoding? encoding, SourceHashAlgorithm checksumAlgorithm, int length)
Text\SourceHashAlgorithms.cs (16)
16public const SourceHashAlgorithm Default = SourceHashAlgorithm.Sha256; 23public const SourceHashAlgorithm OpenDocumentChecksumAlgorithm = Default; 28public static bool IsSupportedAlgorithm(SourceHashAlgorithm algorithm) 31SourceHashAlgorithm.Sha1 => true, 32SourceHashAlgorithm.Sha256 => true, 36public static Guid GetAlgorithmGuid(SourceHashAlgorithm algorithm) 39SourceHashAlgorithm.Sha1 => s_guidSha1, 40SourceHashAlgorithm.Sha256 => s_guidSha256, 44public static SourceHashAlgorithm GetSourceHashAlgorithm(Guid guid) 45=> (guid == s_guidSha256) ? SourceHashAlgorithm.Sha256 : 46(guid == s_guidSha1) ? SourceHashAlgorithm.Sha1 : 47SourceHashAlgorithm.None; 49private static HashAlgorithm CreateInstance(SourceHashAlgorithm algorithm) 54SourceHashAlgorithm.Sha1 => SHA1.Create(), 55SourceHashAlgorithm.Sha256 => SHA256.Create(),
Text\SourceText.cs (25)
36private readonly SourceHashAlgorithm _checksumAlgorithm; 50protected SourceText(ImmutableArray<byte> checksum = default, SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1, SourceTextContainer? container = null) 64internal SourceText(ImmutableArray<byte> checksum, SourceHashAlgorithm checksumAlgorithm, ImmutableArray<byte> embeddedTextBlob) 82internal static void ValidateChecksumAlgorithm(SourceHashAlgorithm checksumAlgorithm) 105public static SourceText From(string text, Encoding? encoding = null, SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1) 135SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1) 154public static SourceText From(Stream stream, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected) 183SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1, 225public static SourceText From(byte[] buffer, int length, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected) 253SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1, 384public SourceHashAlgorithm ChecksumAlgorithm => _checksumAlgorithm; 424/// If this text was constructed via <see cref="From(byte[], int, Encoding, SourceHashAlgorithm, bool, bool)"/> or 425/// <see cref="From(Stream, Encoding, SourceHashAlgorithm, bool, bool)"/>, then the canBeEmbedded arg must have 685internal static ImmutableArray<byte> CalculateChecksum(byte[] buffer, int offset, int count, SourceHashAlgorithm algorithmId) 694internal static ImmutableArray<byte> CalculateChecksum(Stream stream, SourceHashAlgorithm algorithmId) 1325/// If <paramref name="checksumAlgorithm"/> is <see cref="SourceHashAlgorithm.None"/>, returns this instance without modification. 1328internal SourceText WithChecksumAlgorithmIfAny(SourceHashAlgorithm checksumAlgorithm) 1330if (checksumAlgorithm == SourceHashAlgorithm.None || checksumAlgorithm == ChecksumAlgorithm) 1340public SourceTextWithAlgorithm(SourceText underlying, SourceHashAlgorithm checksumAlgorithm) : base(checksumAlgorithm: checksumAlgorithm) 1342Debug.Assert(checksumAlgorithm != SourceHashAlgorithm.None);
Text\SourceTextWriter.cs (1)
14public static SourceTextWriter Create(Encoding? encoding, SourceHashAlgorithm checksumAlgorithm, int length)
Text\StringBuilderText.cs (1)
24public StringBuilderText(StringBuilder builder, Encoding? encodingOpt, SourceHashAlgorithm checksumAlgorithm)
Text\StringText.cs (2)
27SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1,
Text\StringTextWriter.cs (2)
21private readonly SourceHashAlgorithm _checksumAlgorithm; 23public StringTextWriter(Encoding? encoding, SourceHashAlgorithm checksumAlgorithm, int capacity)
Microsoft.CodeAnalysis.Analyzers (9)
src\Compilers\Core\Portable\EncodedStringText.cs (8)
54/// from <see cref="SourceText.From(Stream, Encoding, SourceHashAlgorithm, bool)"/> in two ways: 74SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1, 87SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1, 130SourceHashAlgorithm checksumAlgorithm, 230internal static SourceText Create(Stream stream, Lazy<Encoding> getEncoding, Encoding defaultEncoding, SourceHashAlgorithm checksumAlgorithm, bool canBeEmbedded) 233internal static SourceText Decode(Stream data, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded)
src\RoslynAnalyzers\Utilities\Compiler\Extensions\AdditionalTextExtensions.cs (1)
15private static readonly SourceText s_emptySourceText = SourceText.From("", s_utf8bom, SourceHashAlgorithm.Sha256);
Microsoft.CodeAnalysis.AnalyzerUtilities (9)
src\Compilers\Core\Portable\EncodedStringText.cs (8)
54/// from <see cref="SourceText.From(Stream, Encoding, SourceHashAlgorithm, bool)"/> in two ways: 74SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1, 87SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1, 130SourceHashAlgorithm checksumAlgorithm, 230internal static SourceText Create(Stream stream, Lazy<Encoding> getEncoding, Encoding defaultEncoding, SourceHashAlgorithm checksumAlgorithm, bool canBeEmbedded) 233internal static SourceText Decode(Stream data, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded)
src\RoslynAnalyzers\Utilities\Compiler\Extensions\AdditionalTextExtensions.cs (1)
15private static readonly SourceText s_emptySourceText = SourceText.From("", s_utf8bom, SourceHashAlgorithm.Sha256);
Microsoft.CodeAnalysis.BannedApiAnalyzers (9)
src\Compilers\Core\Portable\EncodedStringText.cs (8)
54/// from <see cref="SourceText.From(Stream, Encoding, SourceHashAlgorithm, bool)"/> in two ways: 74SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1, 87SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1, 130SourceHashAlgorithm checksumAlgorithm, 230internal static SourceText Create(Stream stream, Lazy<Encoding> getEncoding, Encoding defaultEncoding, SourceHashAlgorithm checksumAlgorithm, bool canBeEmbedded) 233internal static SourceText Decode(Stream data, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded)
src\RoslynAnalyzers\Utilities\Compiler\Extensions\AdditionalTextExtensions.cs (1)
15private static readonly SourceText s_emptySourceText = SourceText.From("", s_utf8bom, SourceHashAlgorithm.Sha256);
Microsoft.CodeAnalysis.CodeStyle (8)
src\Compilers\Core\Portable\EncodedStringText.cs (8)
54/// from <see cref="SourceText.From(Stream, Encoding, SourceHashAlgorithm, bool)"/> in two ways: 74SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1, 87SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1, 130SourceHashAlgorithm checksumAlgorithm, 230internal static SourceText Create(Stream stream, Lazy<Encoding> getEncoding, Encoding defaultEncoding, SourceHashAlgorithm checksumAlgorithm, bool canBeEmbedded) 233internal static SourceText Decode(Stream data, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded)
Microsoft.CodeAnalysis.CSharp (15)
CommandLine\CSharpCommandLineParser.cs (3)
112var checksumAlgorithm = SourceHashAlgorithms.Default; 401var newChecksumAlgorithm = TryParseHashAlgorithmName(value!); 402if (newChecksumAlgorithm == SourceHashAlgorithm.None)
CommandLine\CSharpCompiler.cs (1)
376private protected override GeneratorDriver CreateGeneratorDriver(string baseDirectory, ParseOptions parseOptions, ImmutableArray<ISourceGenerator> generators, AnalyzerConfigOptionsProvider analyzerConfigOptionsProvider, ImmutableArray<AdditionalText> additionalTexts, SourceHashAlgorithm checksumAlgorithm)
Syntax\CSharpSyntaxTree.cs (5)
347checksumAlgorithm: SourceHashAlgorithm.Sha1, 361SourceHashAlgorithm checksumAlgorithm) 401checksumAlgorithm: SourceHashAlgorithm.Sha1, 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)
19private const SourceHashAlgorithm ChecksumAlgorithm = SourceHashAlgorithm.Sha1;
Syntax\CSharpSyntaxTree.ParsedSyntaxTree.cs (2)
27private readonly SourceHashAlgorithm _checksumAlgorithm; 34SourceHashAlgorithm checksumAlgorithm,
Syntax\SyntaxFactory.cs (2)
1577=> CSharpSyntaxTree.Create((CSharpSyntaxNode)root, (CSharpParseOptions?)options ?? CSharpParseOptions.Default, path, encoding, SourceHashAlgorithm.Sha1); 1591return CSharpSyntaxTree.ParseText(SourceText.From(text, encoding, SourceHashAlgorithm.Sha1), (CSharpParseOptions?)options, path, diagnosticOptions: null, isGeneratedCode: null, cancellationToken);
Microsoft.CodeAnalysis.CSharp.CommandLine.UnitTests (5)
CommandLineTests.cs (5)
5826Assert.Equal(SourceHashAlgorithm.Sha1, parsedArgs.ChecksumAlgorithm); 5831Assert.Equal(SourceHashAlgorithm.Sha256, parsedArgs.ChecksumAlgorithm); 5837Assert.Equal(SourceHashAlgorithm.Sha256, parsedArgs.ChecksumAlgorithm); 14038context.AddSource("hint2", SourceText.From("class G2 { void F() {} }", Encoding.UTF8, checksumAlgorithm: SourceHashAlgorithm.Sha1)); 14080context.AddSource("hint2", SourceText.From("class G2 { void F() {} }", Encoding.UTF8, checksumAlgorithm: SourceHashAlgorithm.Sha256));
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (1)
PdbSourceDocument\PdbSourceDocumentLoaderServiceTests.cs (1)
72var sourceDocument = new SourceDocument("goo.cs", Text.SourceHashAlgorithm.None, default, null, SourceLinkUrl: null);
Microsoft.CodeAnalysis.CSharp.Emit2.UnitTests (4)
PDB\CheckSumTest.cs (2)
34var tree1 = SyntaxFactory.ParseSyntaxTree(StringText.From(source1, Encoding.UTF8, SourceHashAlgorithm.Sha1), path: "sha1.cs"); 35var tree256 = SyntaxFactory.ParseSyntaxTree(StringText.From(source256, Encoding.UTF8, SourceHashAlgorithm.Sha256), path: "sha256.cs");
PDB\PDBTests.cs (2)
104context.AddSource("hint2", SourceText.From("class G2 { void F() {} }", Encoding.UTF8, checksumAlgorithm: SourceHashAlgorithm.Sha256)); 106Assert.Throws<ArgumentException>(() => context.AddSource("hint3", SourceText.From("class G3 { void F() {} }", encoding: null, checksumAlgorithm: SourceHashAlgorithm.Sha256)));
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (9)
Syntax\Mocks\MockCSharpSyntaxTree.cs (1)
29_sourceText = source ?? SourceText.From("", Encoding.UTF8, SourceHashAlgorithm.Sha256);
Syntax\SyntaxFactoryTests.cs (2)
47Assert.Equal(SourceHashAlgorithm.Sha1, text.ChecksumAlgorithm); 55Assert.Equal(SourceHashAlgorithm.Sha1, text.ChecksumAlgorithm);
Syntax\SyntaxTreeTests.cs (6)
86SyntaxTreeFactoryKind.ParseText => CSharpSyntaxTree.ParseText(SourceText.From(source, Encoding.UTF8, SourceHashAlgorithm.Sha256), parseOptions), 87SyntaxTreeFactoryKind.Subclass => new MockCSharpSyntaxTree(root, SourceText.From(source, Encoding.UTF8, SourceHashAlgorithm.Sha256), parseOptions), 122Assert.Equal(SourceHashAlgorithm.Sha1, tree.GetText().ChecksumAlgorithm); 134Assert.Equal(SourceHashAlgorithm.Sha1, tree.GetText().ChecksumAlgorithm); 253Assert.Equal(SourceHashAlgorithm.Sha1, newText.ChecksumAlgorithm); 295Assert.Equal(SourceHashAlgorithm.Sha1, newText.ChecksumAlgorithm);
Microsoft.CodeAnalysis.CSharp.Test.Utilities (3)
CSharpTestBase.cs (2)
1614public static SyntaxTree Parse(string text, string filename = "", CSharpParseOptions? options = null, Encoding? encoding = null, SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1)
CSharpTestSource.cs (1)
39SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithms.Default)
Microsoft.CodeAnalysis.CSharp.Workspaces (3)
Workspace\LanguageServices\CSharpSyntaxTreeFactoryService.cs (1)
58public override SyntaxTree CreateSyntaxTree(string filePath, ParseOptions options, SourceText text, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, SyntaxNode root)
Workspace\LanguageServices\CSharpSyntaxTreeFactoryService.ParsedSyntaxTree.cs (2)
20private readonly SourceHashAlgorithm _checksumAlgorithm; 34SourceHashAlgorithm checksumAlgorithm)
Microsoft.CodeAnalysis.EditorFeatures (4)
EditAndContinue\PdbMatchingSourceTextProvider.cs (1)
128public async ValueTask<string?> TryGetMatchingSourceTextAsync(string filePath, ImmutableArray<byte> requiredChecksum, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken)
Workspaces\EditorTextFactoryService.cs (3)
32public SourceText CreateText(Stream stream, Encoding? defaultEncoding, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken) 65public SourceText CreateText(TextReader reader, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken) 77private SourceText CreateTextInternal(Stream stream, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken)
Microsoft.CodeAnalysis.EditorFeatures.Text (4)
Extensions.cs (1)
45internal static SourceText AsRoslynText(this ITextSnapshot textSnapshot, ITextBufferCloneService textBufferCloneServiceOpt, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm)
Extensions.SnapshotSourceText.cs (3)
37private SnapshotSourceText(ITextBufferCloneService? textBufferCloneService, ITextSnapshot editorSnapshot, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm, TextBufferContainer container) 48public SnapshotSourceText(ITextBufferCloneService? textBufferCloneService, ITextImage textImage, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm, TextBufferContainer? container) 266public ClosedSnapshotSourceText(ITextBufferCloneService? textBufferCloneService, ITextImage textImage, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm)
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (1)
EditAndContinue\EditAndContinueLanguageServiceTests.cs (1)
397Text = SourceText.From("class C1 { void M() { System.Console.WriteLine(\"c\"); } }", Encoding.UTF8, SourceHashAlgorithm.Sha1)
Microsoft.CodeAnalysis.ExternalAccess.Copilot (1)
SemanticSearch\CopilotSemanticSearchUtilities.cs (1)
30public static SyntaxTree CreateSyntaxTree(SolutionServices services, string language, string? filePath, ParseOptions options, SourceText? text, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm, SyntaxNode root)
Microsoft.CodeAnalysis.ExternalAccess.HotReload (1)
Api\HotReloadMSBuildWorkspace.cs (1)
210private static async ValueTask<SourceText> GetSourceTextAsync(string filePath, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken)
Microsoft.CodeAnalysis.ExternalAccess.HotReload.UnitTests (6)
HotReloadMSBuildWorkspaceTests.cs (6)
46loader: TextLoader.From(TextAndVersion.Create(SourceText.From("class A;", Encoding.UTF8, SourceHashAlgorithm.Sha256), VersionStamp.Create()))) 55.WithChecksumAlgorithm(SourceHashAlgorithm.Sha256) 83loader: TextLoader.From(TextAndVersion.Create(SourceText.From("class C;", Encoding.UTF8, SourceHashAlgorithm.Sha256), VersionStamp.Create()))), 88loader: TextLoader.From(TextAndVersion.Create(SourceText.From("class C;", Encoding.UTF8, SourceHashAlgorithm.Sha256), VersionStamp.Create()))) 97.WithChecksumAlgorithm(SourceHashAlgorithm.Sha256) 119Assert.Equal(SourceHashAlgorithm.Sha256, project2.State.ChecksumAlgorithm);
Microsoft.CodeAnalysis.Features (20)
EditAndContinue\CommittedSolution.cs (7)
329var maybePdbHasDocument = TryReadSourceFileDebugInfo(document, sourceText.Encoding, out var requiredChecksum, out var checksumAlgorithm, out var defaultEncoding); 354SourceHashAlgorithm checksumAlgorithm, 417private static bool IsMatchingSourceText(SourceText sourceText, ImmutableArray<byte> requiredChecksum, SourceHashAlgorithm checksumAlgorithm) 425SourceHashAlgorithm checksumAlgorithm) 452private bool? TryReadSourceFileDebugInfo(Document document, Encoding? documentEncoding, out ImmutableArray<byte> checksum, out SourceHashAlgorithm checksumAlgorithm, out Encoding? defaultEncoding) 498out SourceHashAlgorithm algorithm) 512if (algorithm == SourceHashAlgorithm.None)
EditAndContinue\IPdbMatchingSourceTextProvider.cs (2)
16ValueTask<string?> TryGetMatchingSourceTextAsync(string filePath, ImmutableArray<byte> requiredChecksum, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken); 27public ValueTask<string?> TryGetMatchingSourceTextAsync(string filePath, ImmutableArray<byte> requiredChecksum, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken)
EditAndContinue\Remote\IRemoteEditAndContinueService.cs (1)
26ValueTask<string?> TryGetMatchingSourceTextAsync(RemoteServiceCallbackId callbackId, string filePath, ImmutableArray<byte> requiredChecksum, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken);
EditAndContinue\Remote\RemoteEditAndContinueServiceProxy.cs (2)
35public ValueTask<string?> TryGetMatchingSourceTextAsync(RemoteServiceCallbackId callbackId, string filePath, ImmutableArray<byte> requiredChecksum, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken) 56public async ValueTask<string?> TryGetMatchingSourceTextAsync(string filePath, ImmutableArray<byte> requiredChecksum, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken)
MetadataAsSource\MetadataAsSourceGeneratedFileInfo.cs (1)
22public static SourceHashAlgorithm ChecksumAlgorithm => SourceHashAlgorithms.Default;
PdbSourceDocument\DocumentDebugInfoReader.cs (1)
48var hashAlgorithm = SourceHashAlgorithms.GetSourceHashAlgorithm(hashAlgorithmGuid);
PdbSourceDocument\IPdbSourceDocumentLoaderService.cs (1)
23internal sealed record SourceFileInfo(string FilePath, string SourceDescription, TextLoader Loader, SourceHashAlgorithm ChecksumAlgorithm, bool FromRemoteLocation);
PdbSourceDocument\PdbSourceDocumentMetadataAsSourceFileProvider.cs (4)
214var projectChecksumAlgorithm = sourceDocuments[0].ChecksumAlgorithm; 295private ProjectInfo? CreateProjectInfo(Workspace workspace, Project project, ImmutableDictionary<string, string> pdbCompilationOptions, string assemblyName, string assemblyVersion, SourceHashAlgorithm checksumAlgorithm) 432internal sealed record SourceDocument(string FilePath, SourceHashAlgorithm ChecksumAlgorithm, ImmutableArray<byte> Checksum, byte[]? EmbeddedTextBytes, string? SourceLinkUrl); 434internal record struct SourceDocumentInfo(DocumentId DocumentId, Encoding Encoding, SourceHashAlgorithm ChecksumAlgorithm, ProjectId SourceProjectId, Workspace SourceWorkspace, DocumentInfo DocumentInfo);
Workspace\MiscellaneousFileUtilities.cs (1)
23SourceHashAlgorithm checksumAlgorithm,
Microsoft.CodeAnalysis.Features.Test.Utilities (10)
EditAndContinue\EditAndContinueWorkspaceTestBase.cs (8)
285SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithms.Default, 312SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithms.Default, 339SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithms.Default, 360internal static SourceText CreateText(string source, Encoding? encoding = null, SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithms.Default) 372SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithms.Default, 439SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithms.Default, 444SourceHashAlgorithm.Sha1 => HashAlgorithmName.SHA1, 445SourceHashAlgorithm.Sha256 => HashAlgorithmName.SHA256,
EditAndContinue\MockPdbMatchingSourceTextProvider.cs (2)
16public Func<string, ImmutableArray<byte>, SourceHashAlgorithm, string?>? TryGetMatchingSourceTextImpl { get; set; } 18public ValueTask<string?> TryGetMatchingSourceTextAsync(string filePath, ImmutableArray<byte> requiredChecksum, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken)
Microsoft.CodeAnalysis.Features.UnitTests (12)
EditAndContinue\EditAndContinueMethodDebugInfoReaderTests.cs (1)
65var tree = CSharpTestSource.Parse(source, path: "/a/c.cs", options: TestOptions.Regular.WithNoRefSafetyRulesAttribute(), checksumAlgorithm: SourceHashAlgorithm.Sha1);
EditAndContinue\EditAndContinueWorkspaceServiceTests.cs (11)
68var sourceTreeC1 = SyntaxFactory.ParseSyntaxTree(SourceText.From(sourceBytesC1, sourceBytesC1.Length, encodingC, SourceHashAlgorithm.Sha1), TestOptions.Regular, sourceFileC.Path); 84.WithProjectChecksumAlgorithm(projectPId, SourceHashAlgorithm.Sha1); 115Assert.Equal(SourceHashAlgorithm.Sha1, solution.GetDocument(documentIdA).GetTextSynchronously(default).ChecksumAlgorithm); 116Assert.Equal(SourceHashAlgorithm.Sha1, solution.GetDocument(documentIdB).GetTextSynchronously(default).ChecksumAlgorithm); 117Assert.Equal(SourceHashAlgorithm.Sha1, solution.GetDocument(documentIdC).GetTextSynchronously(default).ChecksumAlgorithm); 118Assert.Equal(SourceHashAlgorithm.Sha1, solution.GetDocument(documentIdE).GetTextSynchronously(default).ChecksumAlgorithm); 1150AddDocument("a.cs", SourceText.From(source1, Encoding.UTF8, SourceHashAlgorithm.Sha1), filePath: sourceFile.Path); 1556WithProjectChecksumAlgorithm(projectId, SourceHashAlgorithm.Sha1). 1557AddDocument(documentId = DocumentId.CreateNewId(projectId), "test.cs", SourceText.From(editorSource, editorEncoding, SourceHashAlgorithm.Sha1), filePath: sourceFile.Path); 1561var moduleId = EmitAndLoadLibraryToDebuggee(projectId, fileSource, sourceFilePath: sourceFile.Path, encoding: compilerEncoding, defaultEncoding: defaultEncoding, checksumAlgorithm: SourceHashAlgorithm.Sha256); 2490context.AddSource("generated.cs", SourceText.From("generated: " + additionalText, Encoding.UTF8, SourceHashAlgorithm.Sha256));
Microsoft.CodeAnalysis.LanguageServer (1)
FileBasedPrograms\CanonicalMiscFilesProjectLoader.cs (1)
335checksumAlgorithm: SourceHashAlgorithm.Sha1,
Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers (9)
src\Compilers\Core\Portable\EncodedStringText.cs (8)
54/// from <see cref="SourceText.From(Stream, Encoding, SourceHashAlgorithm, bool)"/> in two ways: 74SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1, 87SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1, 130SourceHashAlgorithm checksumAlgorithm, 230internal static SourceText Create(Stream stream, Lazy<Encoding> getEncoding, Encoding defaultEncoding, SourceHashAlgorithm checksumAlgorithm, bool canBeEmbedded) 233internal static SourceText Decode(Stream data, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded)
src\RoslynAnalyzers\Utilities\Compiler\Extensions\AdditionalTextExtensions.cs (1)
15private static readonly SourceText s_emptySourceText = SourceText.From("", s_utf8bom, SourceHashAlgorithm.Sha256);
Microsoft.CodeAnalysis.PublicApiAnalyzers (9)
src\Compilers\Core\Portable\EncodedStringText.cs (8)
54/// from <see cref="SourceText.From(Stream, Encoding, SourceHashAlgorithm, bool)"/> in two ways: 74SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1, 87SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1, 130SourceHashAlgorithm checksumAlgorithm, 230internal static SourceText Create(Stream stream, Lazy<Encoding> getEncoding, Encoding defaultEncoding, SourceHashAlgorithm checksumAlgorithm, bool canBeEmbedded) 233internal static SourceText Decode(Stream data, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded)
src\RoslynAnalyzers\Utilities\Compiler\Extensions\AdditionalTextExtensions.cs (1)
15private static readonly SourceText s_emptySourceText = SourceText.From("", s_utf8bom, SourceHashAlgorithm.Sha256);
Microsoft.CodeAnalysis.Rebuild (5)
CompilationOptionsReader.cs (4)
187var hashAlgorithm = 188hashAlgorithmGuid == HashAlgorithmSha1 ? SourceHashAlgorithm.Sha1 189: hashAlgorithmGuid == HashAlgorithmSha256 ? SourceHashAlgorithm.Sha256 190: SourceHashAlgorithm.None;
Records.cs (1)
21SourceHashAlgorithm HashAlgorithm,
Microsoft.CodeAnalysis.Rebuild.UnitTests (14)
BasicDeterministicKeyBuilderTests.cs (1)
30protected override SyntaxTree ParseSyntaxTree(string content, string fileName, SourceHashAlgorithm hashAlgorithm, VisualBasicParseOptions? parseOptions) =>
CSharpDeterministicKeyBuilderTests.cs (5)
27protected override SyntaxTree ParseSyntaxTree(string content, string fileName, SourceHashAlgorithm hashAlgorithm, CSharpParseOptions? parseOptions) => 77CSharpTestSource.Parse(@"System.Console.WriteLine(""Hello World"");", checksumAlgorithm: SourceHashAlgorithm.Sha1), 156checksumAlgorithm: SourceHashAlgorithm.Sha1); 689var tree1 = CSharpTestBase.Parse(source1, filename: "file1.cs", checksumAlgorithm: SourceHashAlgorithm.Sha1); 690var tree2 = CSharpTestBase.Parse(source2, filename: "file2.cs", checksumAlgorithm: SourceHashAlgorithm.Sha256);
DeterministicKeyBuilderTests.cs (8)
36public static SourceHashAlgorithm HashAlgorithm { get; } = SourceHashAlgorithm.Sha256; 37public static SourceHashAlgorithm[] HashAlgorithms { get; } = new[] 39SourceHashAlgorithm.Sha1, 40SourceHashAlgorithm.Sha256 183var syntaxTree = ParseSyntaxTree("", fileName: "test", SourceHashAlgorithm.Sha256, (TParseOptions)parseOptions); 268protected abstract SyntaxTree ParseSyntaxTree(string content, string fileName, SourceHashAlgorithm hashAlgorithm, TParseOptions? parseOptions = null); 287foreach (var hashAlgorithm in HashAlgorithms)
Microsoft.CodeAnalysis.Remote.ServiceHub (1)
Services\EditAndContinue\RemoteEditAndContinueService.cs (1)
62public ValueTask<string?> TryGetMatchingSourceTextAsync(string filePath, ImmutableArray<byte> requiredChecksum, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken)
Microsoft.CodeAnalysis.Remote.Workspaces (1)
EditAndContinue\ManagedHotReloadLanguageService.cs (1)
38public async ValueTask<string?> TryGetMatchingSourceTextAsync(string filePath, ImmutableArray<byte> requiredChecksum, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken)
Microsoft.CodeAnalysis.ResxSourceGenerator (12)
AbstractResxGenerator.cs (3)
209var errorText = SourceText.From(text, Encoding.UTF8, SourceHashAlgorithm.Sha256); 349OutputText = SourceText.From(result, Encoding.UTF8, SourceHashAlgorithm.Sha256); 742OutputText = SourceText.From(result, Encoding.UTF8, SourceHashAlgorithm.Sha256);
src\Compilers\Core\Portable\EncodedStringText.cs (8)
54/// from <see cref="SourceText.From(Stream, Encoding, SourceHashAlgorithm, bool)"/> in two ways: 74SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1, 87SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1, 130SourceHashAlgorithm checksumAlgorithm, 230internal static SourceText Create(Stream stream, Lazy<Encoding> getEncoding, Encoding defaultEncoding, SourceHashAlgorithm checksumAlgorithm, bool canBeEmbedded) 233internal static SourceText Decode(Stream data, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded)
src\RoslynAnalyzers\Utilities\Compiler\Extensions\AdditionalTextExtensions.cs (1)
15private static readonly SourceText s_emptySourceText = SourceText.From("", s_utf8bom, SourceHashAlgorithm.Sha256);
Microsoft.CodeAnalysis.ResxSourceGenerator.UnitTests (2)
Verifiers\CSharpSourceGeneratorVerifier`1+Test.cs (1)
124TestState.GeneratedSources.Add((typeof(TSourceGenerator), name, SourceText.From(reader.ReadToEnd(), Encoding.UTF8, SourceHashAlgorithm.Sha256)));
Verifiers\VisualBasicSourceGeneratorVerifier`1+Test.cs (1)
109TestState.GeneratedSources.Add((typeof(VisualBasicResxGenerator), name, SourceText.From(reader.ReadToEnd(), Encoding.UTF8, SourceHashAlgorithm.Sha256)));
Microsoft.CodeAnalysis.Test.Utilities (2)
Mocks\TestAdditionalText.cs (2)
22public TestAdditionalText(string text = "", Encoding? encoding = null, string path = "dummy", SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1)
Microsoft.CodeAnalysis.UnitTests (48)
EmbeddedTextTests.cs (26)
28Assert.Throws<ArgumentException>("checksumAlgorithm", () => EmbeddedText.FromBytes("path", new ArraySegment<byte>(new byte[0], 0, 0), SourceHashAlgorithm.None)); 54Assert.Throws<ArgumentException>("checksumAlgorithm", () => EmbeddedText.FromStream("path", new MemoryStream(), SourceHashAlgorithm.None)); 81var text = EmbeddedText.FromBytes("pathToEmpty", new ArraySegment<byte>(new byte[0], 0, 0), SourceHashAlgorithm.Sha1); 83Assert.Equal(SourceHashAlgorithm.Sha1, text.ChecksumAlgorithm); 84AssertEx.Equal(SourceText.CalculateChecksum(new byte[0], 0, 0, SourceHashAlgorithm.Sha1), text.Checksum); 91var text = EmbeddedText.FromStream("pathToEmpty", new MemoryStream(new byte[0]), SourceHashAlgorithm.Sha1); 92var checksum = SourceText.CalculateChecksum(new byte[0], 0, 0, SourceHashAlgorithm.Sha1); 95Assert.Equal(SourceHashAlgorithm.Sha1, text.ChecksumAlgorithm); 103var source = SourceText.From("", new UTF8Encoding(encoderShouldEmitUTF8Identifier: false), SourceHashAlgorithm.Sha1); 105var checksum = SourceText.CalculateChecksum(new byte[0], 0, 0, SourceHashAlgorithm.Sha1); 108Assert.Equal(SourceHashAlgorithm.Sha1, text.ChecksumAlgorithm); 117var checksum = SourceText.CalculateChecksum(bytes, 0, bytes.Length, SourceHashAlgorithm.Sha1); 121Assert.Equal(SourceHashAlgorithm.Sha1, text.ChecksumAlgorithm); 132var checksum = SourceText.CalculateChecksum(bytes, 0, bytes.Length, SourceHashAlgorithm.Sha1); 137Assert.Equal(SourceHashAlgorithm.Sha1, text.ChecksumAlgorithm); 145var source = SourceText.From(SmallSource, Encoding.UTF8, SourceHashAlgorithm.Sha1); 149Assert.Equal(SourceHashAlgorithm.Sha1, text.ChecksumAlgorithm); 200var expected = SourceText.From(SmallSource, Encoding.UTF8, SourceHashAlgorithm.Sha1); 203var actual = SourceText.From(new StringReader(SmallSource), SmallSource.Length, Encoding.UTF8, SourceHashAlgorithm.Sha1); 215var expected = SourceText.From(LargeSource, Encoding.UTF8, SourceHashAlgorithm.Sha1); 218var actual = SourceText.From(new StringReader(LargeSource), LargeSource.Length, Encoding.UTF8, SourceHashAlgorithm.Sha1); 236SourceText.From(new MemoryStream(bytes), Encoding.ASCII, SourceHashAlgorithm.Sha1, canBeEmbedded: true) : 237SourceText.From(bytes, bytes.Length, Encoding.ASCII, SourceHashAlgorithm.Sha1, canBeEmbedded: true); 241Assert.Equal(SourceHashAlgorithm.Sha1, text.ChecksumAlgorithm); 242AssertEx.Equal(SourceText.CalculateChecksum(bytes, 0, bytes.Length, SourceHashAlgorithm.Sha1), source.GetChecksum()); 256Assert.Equal(SourceHashAlgorithm.Sha1, text.ChecksumAlgorithm);
Text\LargeTextTests.cs (2)
33return LargeText.Decode(stream, encoding ?? Encoding.UTF8, SourceHashAlgorithm.Sha1, throwIfBinaryDetected: true, canBeEmbedded: false); 38return LargeText.Decode(reader, length, encoding ?? Encoding.UTF8, SourceHashAlgorithm.Sha1);
Text\SourceTextTests.cs (12)
85Assert.Equal(SourceHashAlgorithm.Sha1, SourceText.From(HelloWorld).ChecksumAlgorithm); 88Assert.Equal(SourceHashAlgorithm.Sha1, SourceText.From(bytes, bytes.Length).ChecksumAlgorithm); 91Assert.Equal(SourceHashAlgorithm.Sha1, SourceText.From(stream).ChecksumAlgorithm); 95[InlineData(SourceHashAlgorithm.Sha1)] 96[InlineData(SourceHashAlgorithm.Sha256)] 97public void ChecksumAlgorithm1(SourceHashAlgorithm algorithm) 111var checksumAlgorithm = SourceHashAlgorithm.Sha1; 201private static SourceText FromLargeTextWriter(string source, Encoding encoding, SourceHashAlgorithm checksumAlgorithm) 252var hashAlgorithms = new[] { SourceHashAlgorithm.Sha1, SourceHashAlgorithm.Sha256 }; 265foreach (var algorithm in hashAlgorithms)
Text\StringTextDecodingTests.cs (8)
19private static SourceText CreateMemoryStreamBasedEncodedText(string text, Encoding writeEncoding, Encoding readEncodingOpt, SourceHashAlgorithm algorithm = SourceHashAlgorithm.Sha1) 26private static SourceText CreateMemoryStreamBasedEncodedText(byte[] bytes, Encoding readEncodingOpt, SourceHashAlgorithm algorithm = SourceHashAlgorithm.Sha1) 42SourceHashAlgorithm algorithm = SourceHashAlgorithm.Sha1) 134var data = CreateMemoryStreamBasedEncodedText("", Encoding.UTF8, readEncodingOpt: null, algorithm: SourceHashAlgorithm.Sha256); 161EncodedStringText.TestAccessor.Decode(stream, utf8, SourceHashAlgorithm.Sha1, throwIfBinaryDetected: false, canBeEmbedded: false);
Microsoft.CodeAnalysis.VisualBasic (11)
CommandLine\VisualBasicCommandLineParser.vb (1)
359If newChecksumAlgorithm = SourceHashAlgorithm.None Then
CommandLine\VisualBasicCompiler.vb (1)
301Private Protected Overrides Function CreateGeneratorDriver(baseDirectory As String, parseOptions As ParseOptions, generators As ImmutableArray(Of ISourceGenerator), analyzerConfigOptionsProvider As AnalyzerConfigOptionsProvider, additionalTexts As ImmutableArray(Of AdditionalText), checksumAlgorithm As SourceHashAlgorithm) As GeneratorDriver
Syntax\SyntaxNodeFactories.vb (2)
37Return VisualBasicSyntaxTree.Create(DirectCast(root, VisualBasicSyntaxNode), If(DirectCast(options, VisualBasicParseOptions), VisualBasicParseOptions.Default), path, encoding, SourceHashAlgorithm.Sha1) 50Return ParseSyntaxTree(SourceText.From(text, encoding, SourceHashAlgorithm.Sha1), options, path, cancellationToken)
Syntax\VisualBasicSyntaxTree.DummySyntaxTree.vb (2)
16Private Const ChecksumAlgorithm As SourceHashAlgorithm = SourceHashAlgorithm.Sha1
Syntax\VisualBasicSyntaxTree.ParsedSyntaxTree.vb (2)
28Private ReadOnly _checksumAlgorithm As SourceHashAlgorithm 38checksumAlgorithm As SourceHashAlgorithm,
Syntax\VisualBasicSyntaxTree.vb (3)
175checksumAlgorithm:=SourceHashAlgorithm.Sha1, 187checksumAlgorithm As SourceHashAlgorithm) As SyntaxTree 223checksumAlgorithm:=SourceHashAlgorithm.Sha1,
Microsoft.CodeAnalysis.Workspaces (59)
Serialization\SerializableSourceText.cs (4)
180var checksumAlgorithm = (SourceHashAlgorithm)reader.ReadInt32(); 189var checksumAlgorithm = (SourceHashAlgorithm)reader.ReadInt32();
Shared\Extensions\SourceTextExtensions.cs (1)
226public static SourceText ReadFrom(ITextFactoryService textService, ObjectReader reader, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken)
SourceGeneration\IRemoteSourceGenerationService.cs (1)
90[property: DataMember(Order = 2)] SourceHashAlgorithm ChecksumAlgorithm);
src\Compilers\Core\Portable\EncodedStringText.cs (8)
54/// from <see cref="SourceText.From(Stream, Encoding, SourceHashAlgorithm, bool)"/> in two ways: 74SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1, 87SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1, 130SourceHashAlgorithm checksumAlgorithm, 230internal static SourceText Create(Stream stream, Lazy<Encoding> getEncoding, Encoding defaultEncoding, SourceHashAlgorithm checksumAlgorithm, bool canBeEmbedded) 233internal static SourceText Decode(Stream data, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded)
src\Compilers\Core\Portable\Text\SourceHashAlgorithms.cs (16)
16public const SourceHashAlgorithm Default = SourceHashAlgorithm.Sha256; 23public const SourceHashAlgorithm OpenDocumentChecksumAlgorithm = Default; 28public static bool IsSupportedAlgorithm(SourceHashAlgorithm algorithm) 31SourceHashAlgorithm.Sha1 => true, 32SourceHashAlgorithm.Sha256 => true, 36public static Guid GetAlgorithmGuid(SourceHashAlgorithm algorithm) 39SourceHashAlgorithm.Sha1 => s_guidSha1, 40SourceHashAlgorithm.Sha256 => s_guidSha256, 44public static SourceHashAlgorithm GetSourceHashAlgorithm(Guid guid) 45=> (guid == s_guidSha256) ? SourceHashAlgorithm.Sha256 : 46(guid == s_guidSha1) ? SourceHashAlgorithm.Sha1 : 47SourceHashAlgorithm.None; 49private static HashAlgorithm CreateInstance(SourceHashAlgorithm algorithm) 54SourceHashAlgorithm.Sha1 => SHA1.Create(), 55SourceHashAlgorithm.Sha256 => SHA256.Create(),
TemporaryStorage\TemporaryStorageService.cs (3)
184SourceHashAlgorithm checksumAlgorithm, 248SourceHashAlgorithm checksumAlgorithm, 254public SourceHashAlgorithm ChecksumAlgorithm => checksumAlgorithm;
Workspace\Host\SyntaxTreeFactory\AbstractSyntaxTreeFactoryService.cs (1)
20public abstract SyntaxTree CreateSyntaxTree(string filePath, ParseOptions options, SourceText text, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, SyntaxNode root);
Workspace\Host\SyntaxTreeFactory\ISyntaxTreeFactoryService.cs (1)
30SyntaxTree CreateSyntaxTree(string? filePath, ParseOptions options, SourceText? text, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm, SyntaxNode root);
Workspace\Host\TextFactory\ITextFactoryService.cs (2)
33SourceText CreateText(Stream stream, Encoding? defaultEncoding, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken); 43SourceText CreateText(TextReader reader, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken);
Workspace\Host\TextFactory\TextFactoryService.cs (2)
25public SourceText CreateText(Stream stream, Encoding? defaultEncoding, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken) 31public SourceText CreateText(TextReader reader, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken)
Workspace\ProjectSystem\ProjectSystemProject.cs (1)
429public SourceHashAlgorithm ChecksumAlgorithm
Workspace\Solution\DocumentState.cs (2)
303public DocumentState UpdateChecksumAlgorithm(SourceHashAlgorithm checksumAlgorithm) 533SourceHashAlgorithm checksumAlgorithm,
Workspace\Solution\LoadTextOptions.cs (2)
15public SourceHashAlgorithm ChecksumAlgorithm { get; } 17public LoadTextOptions(SourceHashAlgorithm checksumAlgorithm)
Workspace\Solution\ProjectInfo.cs (9)
88internal SourceHashAlgorithm ChecksumAlgorithm => Attributes.ChecksumAlgorithm; 240checksumAlgorithm: SourceHashAlgorithm.Sha1, 362internal ProjectInfo WithChecksumAlgorithm(SourceHashAlgorithm checksumAlgorithm) 419SourceHashAlgorithm checksumAlgorithm, 488public SourceHashAlgorithm ChecksumAlgorithm { get; } = checksumAlgorithm; 543Optional<SourceHashAlgorithm> checksumAlgorithm = default, 559var newChecksumAlgorithm = checksumAlgorithm.HasValue ? checksumAlgorithm.Value : ChecksumAlgorithm; 643var checksumAlgorithm = (SourceHashAlgorithm)reader.ReadByte();
Workspace\Solution\ProjectState.cs (3)
634public SourceHashAlgorithm ChecksumAlgorithm => this.ProjectInfo.ChecksumAlgorithm; 752public ProjectState WithChecksumAlgorithm(SourceHashAlgorithm checksumAlgorithm) 764private TextDocumentStates<DocumentState> UpdateDocumentsChecksumAlgorithm(SourceHashAlgorithm checksumAlgorithm)
Workspace\Solution\Solution.cs (1)
453internal Solution WithProjectChecksumAlgorithm(ProjectId projectId, SourceHashAlgorithm checksumAlgorithm)
Workspace\Solution\SolutionCompilationState.cs (1)
453ProjectId projectId, SourceHashAlgorithm checksumAlgorithm)
Workspace\Solution\SolutionState.cs (1)
632public StateChange WithProjectChecksumAlgorithm(ProjectId projectId, SourceHashAlgorithm checksumAlgorithm)
Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests (3)
VisualStudioMSBuildWorkspaceTests.cs (3)
287Assert.Equal(SourceHashAlgorithm.Sha1, project.State.ChecksumAlgorithm); 289Assert.All(project.Documents, d => Assert.Equal(SourceHashAlgorithm.Sha1, d.GetTextSynchronously(default).ChecksumAlgorithm)); 290Assert.All(project.AdditionalDocuments, d => Assert.Equal(SourceHashAlgorithm.Sha1, d.GetTextSynchronously(default).ChecksumAlgorithm));
Microsoft.CodeAnalysis.Workspaces.Test.Utilities (2)
TestTextLoader.cs (1)
16public TestTextLoader(string text = "test", SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithms.Default)
Workspaces\TestHostDocument.cs (1)
65public SourceHashAlgorithm ChecksumAlgorithm { get; } = SourceHashAlgorithms.Default;
Microsoft.CodeAnalysis.Workspaces.UnitTests (41)
SolutionTests\ProjectInfoTests.cs (1)
195SolutionTestHelpers.TestProperty(instance, (old, value) => old.WithChecksumAlgorithm(value), opt => opt.ChecksumAlgorithm, SourceHashAlgorithm.None);
SolutionTests\SolutionTests.cs (40)
303Assert.Equal(SourceHashAlgorithm.Sha1, tree.GetText().ChecksumAlgorithm); 362var text = SourceText.From("new text", encoding: null, SourceHashAlgorithm.Sha1); 463var text = SourceText.From("new text", encoding: null, SourceHashAlgorithm.Sha1); 551var text = SourceText.From("new text", encoding: null, SourceHashAlgorithm.Sha1); 634var text = SourceText.From("new text without pp directives", encoding: null, SourceHashAlgorithm.Sha1); 717var text = SourceText.From("#if true", encoding: null, SourceHashAlgorithm.Sha1); 793var text = SourceText.From("new text", encoding: null, SourceHashAlgorithm.Sha1); 880var text = SourceText.From(" ", encoding: null, SourceHashAlgorithm.Sha1); 1103.AddProject(ProjectInfo.Create(projectId, VersionStamp.Default, "proj1", "proj1", LanguageNames.CSharp, Path.Combine(s_projectDir, "proj1.dll")).WithChecksumAlgorithm(SourceHashAlgorithm.Sha1)) 1120loader: TextLoader.From(TextAndVersion.Create(SourceText.From("class NewD1;", Encoding.UTF32, SourceHashAlgorithm.Sha256), VersionStamp.Create(), filePath: Path.Combine(s_projectDir, "newD1.cs"))), 1139loader: TextLoader.From(TextAndVersion.Create(SourceText.From("new text1", Encoding.UTF32, SourceHashAlgorithm.Sha256), VersionStamp.Create(), filePath: Path.Combine(s_projectDir, "newD1.cs"))), 1158loader: TextLoader.From(TextAndVersion.Create(SourceText.From("#new empty1", Encoding.UTF32, SourceHashAlgorithm.Sha256), VersionStamp.Create(), filePath: Path.Combine(s_projectDir, "newD1.cs"))), 1210.WithChecksumAlgorithm(SourceHashAlgorithm.Sha256) 1252Assert.Equal(SourceHashAlgorithm.Sha256, newText1.ChecksumAlgorithm); 1273Assert.Equal(SourceHashAlgorithm.Sha256, newAddText1.ChecksumAlgorithm); 1294Assert.Equal(SourceHashAlgorithm.Sha256, newConfigText1.ChecksumAlgorithm); 1677var textLoaderA = new TestTextLoader("class A {}", SourceHashAlgorithm.Sha1); 1678var textC = SourceText.From("class C {}", encoding: null, checksumAlgorithm: SourceHashAlgorithm.Sha1); 1682.WithProjectChecksumAlgorithm(projectId, SourceHashAlgorithm.Sha1); 1689await Verify(solution.GetRequiredDocument(documentAId), SourceHashAlgorithm.Sha1); 1690await Verify(solution.GetRequiredDocument(documentBId), SourceHashAlgorithm.Sha1); 1691await Verify(solution.GetRequiredDocument(documentCId), SourceHashAlgorithm.Sha1); 1692await Verify(solution.GetRequiredDocument(fileDocumentId), SourceHashAlgorithm.Sha1, checksumSHA1); 1695solution = solution.WithProjectChecksumAlgorithm(projectId, SourceHashAlgorithm.Sha256); 1696await Verify(solution.GetRequiredDocument(documentAId), SourceHashAlgorithm.Sha1); 1697await Verify(solution.GetRequiredDocument(documentBId), SourceHashAlgorithm.Sha1); 1698await Verify(solution.GetRequiredDocument(documentCId), SourceHashAlgorithm.Sha1); 1699await Verify(solution.GetRequiredDocument(fileDocumentId), SourceHashAlgorithm.Sha256, checksumSHA256); 1702solution = solution.WithProjectChecksumAlgorithm(projectId, SourceHashAlgorithm.Sha1); 1703await Verify(solution.GetRequiredDocument(documentAId), SourceHashAlgorithm.Sha1); 1704await Verify(solution.GetRequiredDocument(documentBId), SourceHashAlgorithm.Sha1); 1705await Verify(solution.GetRequiredDocument(documentCId), SourceHashAlgorithm.Sha1); 1706await Verify(solution.GetRequiredDocument(fileDocumentId), SourceHashAlgorithm.Sha1, checksumSHA1); 1708static async Task Verify(Document document, SourceHashAlgorithm expectedAlgorithm, byte[]? expectedChecksum = null) 2427var loader = new TestTextLoader(checksumAlgorithm: SourceHashAlgorithm.Sha1); 2435Assert.Equal(SourceHashAlgorithm.Sha1, document.GetTextSynchronously(default).ChecksumAlgorithm); 2674var root = CSharp.SyntaxFactory.ParseSyntaxTree(SourceText.From("class C {}", encoding: Encoding.ASCII, SourceHashAlgorithm.Sha1)).GetRoot(); 2675Assert.Equal(SourceHashAlgorithm.Sha1, root.SyntaxTree.GetText().ChecksumAlgorithm); 2707Assert.Equal(SourceHashAlgorithm.Sha1, root.SyntaxTree.GetText().ChecksumAlgorithm); 3973.AddDocument(did, "test", SourceText.From(language == LanguageNames.CSharp ? "class C {}" : "Class C : End Class", Encoding.UTF8, SourceHashAlgorithm.Sha256), filePath: "old path");
Microsoft.VisualStudio.LanguageServices (1)
ProjectSystem\MiscellaneousFilesWorkspace.cs (1)
298var checksumAlgorithm = SourceHashAlgorithms.Default;
Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests (1)
ProjectSystemShim\CPS\CSharpCompilerOptionsTests.cs (1)
187Assert.Equal(SourceHashAlgorithm.Sha1, environment.Workspace.CurrentSolution.Projects.Single().State.ChecksumAlgorithm);
Microsoft.VisualStudio.LanguageServices.LiveShare (1)
Client\Projects\RoslynRemoteProjectInfoProvider.cs (1)
90var checksumAlgorithm = SourceHashAlgorithms.Default;
Roslyn.Diagnostics.Analyzers (9)
src\Compilers\Core\Portable\EncodedStringText.cs (8)
54/// from <see cref="SourceText.From(Stream, Encoding, SourceHashAlgorithm, bool)"/> in two ways: 74SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1, 87SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1, 130SourceHashAlgorithm checksumAlgorithm, 230internal static SourceText Create(Stream stream, Lazy<Encoding> getEncoding, Encoding defaultEncoding, SourceHashAlgorithm checksumAlgorithm, bool canBeEmbedded) 233internal static SourceText Decode(Stream data, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded)
src\RoslynAnalyzers\Utilities\Compiler\Extensions\AdditionalTextExtensions.cs (1)
15private static readonly SourceText s_emptySourceText = SourceText.From("", s_utf8bom, SourceHashAlgorithm.Sha256);
Roslyn.VisualStudio.Next.UnitTests (8)
Services\ServiceHubServicesTests.cs (6)
514private static SourceText CreateText(string content, Encoding encoding = null, SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1) 524return SourceText.From(stream, encoding, SourceHashAlgorithm.Sha1, throwIfBinaryDetected: true); 528return SourceText.From(bytes, bytes.Length, encoding, SourceHashAlgorithm.Sha1, throwIfBinaryDetected: true); 600[("SG.cs", CreateText("X", Encoding.UTF8, checksumAlgorithm: SourceHashAlgorithm.Sha1))], 601[("SG.cs", CreateText("X", Encoding.UTF8, checksumAlgorithm: SourceHashAlgorithm.Sha256))]);
Services\SolutionServiceTests.cs (2)
261.WithProjectChecksumAlgorithm(projectId, SourceHashAlgorithm.Sha1 + version) 277Assert.Equal(SourceHashAlgorithm.Sha1 + version, project.State.ChecksumAlgorithm);
StackDepthTest (1)
Program.cs (1)
79var tree = SyntaxFactory.ParseSyntaxTree(SourceText.From(stringText, encoding: null, SourceHashAlgorithm.Sha256), parseOptions);
Test.Utilities (9)
src\Compilers\Core\Portable\EncodedStringText.cs (8)
54/// from <see cref="SourceText.From(Stream, Encoding, SourceHashAlgorithm, bool)"/> in two ways: 74SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1, 87SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1, 130SourceHashAlgorithm checksumAlgorithm, 230internal static SourceText Create(Stream stream, Lazy<Encoding> getEncoding, Encoding defaultEncoding, SourceHashAlgorithm checksumAlgorithm, bool canBeEmbedded) 233internal static SourceText Decode(Stream data, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded)
src\RoslynAnalyzers\Utilities\Compiler\Extensions\AdditionalTextExtensions.cs (1)
15private static readonly SourceText s_emptySourceText = SourceText.From("", s_utf8bom, SourceHashAlgorithm.Sha256);
Text.Analyzers (9)
src\Compilers\Core\Portable\EncodedStringText.cs (8)
54/// from <see cref="SourceText.From(Stream, Encoding, SourceHashAlgorithm, bool)"/> in two ways: 74SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1, 87SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1, 130SourceHashAlgorithm checksumAlgorithm, 230internal static SourceText Create(Stream stream, Lazy<Encoding> getEncoding, Encoding defaultEncoding, SourceHashAlgorithm checksumAlgorithm, bool canBeEmbedded) 233internal static SourceText Decode(Stream data, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded)
src\RoslynAnalyzers\Utilities\Compiler\Extensions\AdditionalTextExtensions.cs (1)
15private static readonly SourceText s_emptySourceText = SourceText.From("", s_utf8bom, SourceHashAlgorithm.Sha256);