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

Code before:
            }

            void writeResources()
            {
                writer.WriteArrayStart();
                foreach (ResourceDescription resource in resources)
                {
                    cancellationToken.ThrowIfCancellationRequested();
                    writer.WriteObjectStart();
                    writer.Write("resourceName", resource.ResourceName);
                    writer.Write("fileName", resource.FileName);
                    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 var stream = resource.DataProvider();
                    var sourceText = SourceText.From(stream, encoding: null, checksumAlgorithm: SourceHashAlgorithms.Default);
                    WriteSourceText(writer, sourceText);
                }
                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");

Review comment (bug):
Why are you converting to a `SourceText` here? These resources are generally treated as binary blobs in the codebase. My intuition would be that we just grab the raw `Stream` or `byte[]` and hash that. Not sure if we'd hit weird edge cases trying to view a binary as a source text. 

Code after:
            }

            void writeResources()
            {
                writer.WriteArrayStart();
                foreach (ResourceDescription resource in resources)
                {
                    cancellationToken.ThrowIfCancellationRequested();
                    writer.WriteObjectStart();
                    writer.Write("resourceName", resource.ResourceName);
                    writer.Write("fileName", resource.FileName);
                    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);