提交 490dff63 编写于 作者: S Sam Harwell

Cleanup and documentation from code review

上级 a9be8869
......@@ -210,7 +210,7 @@ public ImmutableArray<byte> GetChecksum()
{
if (_checksum.IsDefault)
{
_checksum = ReadText(CancellationToken.None).GetChecksum();
ImmutableInterlocked.InterlockedInitialize(ref _checksum, ReadText(CancellationToken.None).GetChecksum());
}
return _checksum;
......
......@@ -10,12 +10,27 @@
namespace Microsoft.CodeAnalysis.Host
{
/// <summary>
/// Represents a <see cref="ITemporaryStorageWithName"/> which is used to hold data for <see cref="SourceText"/>.
/// </summary>
internal interface ITemporaryTextStorageWithName : ITemporaryTextStorage, ITemporaryStorageWithName
{
/// <summary>
/// Gets the value for the <see cref="SourceText.ChecksumAlgorithm"/> property for the <see cref="SourceText"/>
/// represented by this temporary storage.
/// </summary>
SourceHashAlgorithm ChecksumAlgorithm { get; }
/// <summary>
/// Gets the value for the <see cref="SourceText.Encoding"/> property for the <see cref="SourceText"/>
/// represented by this temporary storage.
/// </summary>
Encoding? Encoding { get; }
/// <summary>
/// Gets the checksum for the <see cref="SourceText"/> represented by this temporary storage. This is equivalent
/// to calling <see cref="SourceText.GetChecksum"/>.
/// </summary>
ImmutableArray<byte> GetChecksum();
}
}
......@@ -98,10 +98,11 @@ public async Task<DocumentInfo> CreateDocumentInfoAsync(Checksum documentChecksu
{
var documentSnapshot = await GetAssetAsync<DocumentStateChecksums>(documentChecksum, cancellationToken).ConfigureAwait(false);
var documentInfo = await GetAssetAsync<DocumentInfo.DocumentAttributes>(documentSnapshot.Info, cancellationToken).ConfigureAwait(false);
var serializableSourceText = await GetAssetAsync<SerializableSourceText>(documentSnapshot.Text, cancellationToken).ConfigureAwait(false);
var textLoader = TextLoader.From(
TextAndVersion.Create(
await (await GetAssetAsync<SerializableSourceText>(documentSnapshot.Text, cancellationToken).ConfigureAwait(false)).GetTextAsync(cancellationToken).ConfigureAwait(false),
await serializableSourceText.GetTextAsync(cancellationToken).ConfigureAwait(false),
VersionStamp.Create(),
documentInfo.FilePath));
......
......@@ -33,6 +33,10 @@ internal sealed class SolutionAsset
public SolutionAsset(object? value, Checksum checksum, WellKnownSynchronizationKind kind)
{
// SolutionAsset is not allowed to hold strong references to SourceText. SerializableSourceText is used
// instead to allow data to be released from process address space when it is also held in temporary
// storage.
// https://github.com/dotnet/roslyn/issues/43802
Contract.ThrowIfTrue(kind is WellKnownSynchronizationKind.SourceText);
Checksum = checksum;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册