Repository: dotnet/roslyn
File: src/Compilers/Core/Portable/Compilation/DeterministicKeyBuilder.cs (C#)

Code before:
                    writer.Write("isPublic", resource.IsPublic);
                    writer.WriteKey("content");
                    writeResourceContent(writer, resource);
                    writer.WriteObjectEnd();
                }
                writer.WriteArrayEnd();
            }

            static void writeResourceContent(JsonWriter writer, ResourceDescription resource)
            {
                if (resource.IsEmbedded)
                {
                    writer.WriteObjectStart();
                    WriteByteArrayValue(writer, "checksum", computeChecksum(resource));
                    writer.WriteObjectEnd();
                }
                else
                {
                    writer.WriteNull();
                }
            }

            static Span<byte> computeChecksum(ResourceDescription resource)
            {
                using var stream = resource.DataProvider();
                using var hashAlgorithm = System.Security.Cryptography.SHA256.Create();
                return hashAlgorithm.ComputeHash(stream).AsSpan();
            }
        }

        internal static string GetGuidValue(in Guid guid) => guid.ToString("D");

        private void WriteCompilation(
            JsonWriter writer,
            CompilationOptions compilationOptions,
            ImmutableArray<SyntaxTreeKey> syntaxTrees,
            ImmutableArray<MetadataReference> references,
            ImmutableArray<byte> publicKey,
            ImmutableArray<KeyValuePair<string, string>> pathMap,
            DeterministicKeyOptions options,
            CancellationToken cancellationToken)
        {
            writer.WriteObjectStart();
            writeToolsVersions();

            WriteByteArrayValue(writer, "publicKey", publicKey.AsSpan());
            writer.WriteKey("options");
            WriteCompilationOptions(writer, compilationOptions);

            writer.WriteKey("syntaxTrees");
            writer.WriteArrayStart();

Review comment (suggestion):
:memo: `sourceText.GetChecksum` (in `WriteSourceText`) uses either SHA1 or SHA256. I figured it's okay to align with that for now, but we should consider moving to XXHASH at some point #Resolved

Code after:
                    writer.Write("isPublic", resource.IsPublic);
                    writer.WriteKey("content");
                    writeResourceContent(writer, resource);
                    writer.WriteObjectEnd();
                }
                writer.WriteArrayEnd();
            }

            void writeResourceContent(JsonWriter writer, ResourceDescription resource)
            {
                if (resource.IsEmbedded)
                {
                    using Stream stream = resource.DataProvider();
                    WriteStream(writer, stream);
                }
                else
                {
                    writer.WriteNull();
                }
            }
        }

        internal static string GetGuidValue(in Guid guid) => guid.ToString("D");

        private void WriteCompilation(
            JsonWriter writer,
            CompilationOptions compilationOptions,
            ImmutableArray<SyntaxTreeKey> syntaxTrees,
            ImmutableArray<MetadataReference> references,
            ImmutableArray<byte> publicKey,
            ImmutableArray<KeyValuePair<string, string>> pathMap,
            DeterministicKeyOptions options,
            CancellationToken cancellationToken)
        {
            writer.WriteObjectStart();
            writeToolsVersions();

            WriteByteArrayValue(writer, "publicKey", publicKey.AsSpan());
            writer.WriteKey("options");
            WriteCompilationOptions(writer, compilationOptions);

            writer.WriteKey("syntaxTrees");
            writer.WriteArrayStart();
            foreach (var syntaxTree in syntaxTrees)
            {
                cancellationToken.ThrowIfCancellationRequested();
                WriteSyntaxTree(writer, syntaxTree, pathMap, options, cancellationToken);
            }
            writer.WriteArrayEnd();

            writer.WriteKey("references");