Skip to content

Commit

Permalink
Rename type
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNajmabadi committed Nov 9, 2021
1 parent 5740c55 commit 8dae3c9
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ private partial class CompilationTracker : ICompilationTracker
// guarantees only one thread is building at a time
private readonly SemaphoreSlim _buildLock = new(initialCount: 1);

public CachedSkeletonReferences CachedSkeletonReferences { get; }
public SkeletonReferenceCache SkeletonReferenceCache { get; }

private CompilationTracker(
ProjectState project,
CompilationTrackerState state,
CachedSkeletonReferences cachedSkeletonReferences)
SkeletonReferenceCache cachedSkeletonReferences)
{
Contract.ThrowIfNull(project);

this.ProjectState = project;
_stateDoNotAccessDirectly = state;
this.CachedSkeletonReferences = cachedSkeletonReferences;
this.SkeletonReferenceCache = cachedSkeletonReferences;
}

/// <summary>
Expand Down Expand Up @@ -147,13 +147,13 @@ public ICompilationTracker Fork(
var newState = CompilationTrackerState.Create(
solutionServices, baseCompilation, state.GeneratorInfo, state.FinalCompilationWithGeneratedDocuments?.GetValueOrNull(cancellationToken), intermediateProjects);

return new CompilationTracker(newProject, newState, this.CachedSkeletonReferences.Clone());
return new CompilationTracker(newProject, newState, this.SkeletonReferenceCache.Clone());
}
else
{
// We have no compilation, but we might have information about generated docs.
var newState = new NoCompilationState(state.GeneratorInfo.WithDocumentsAreFinal(false));
return new CompilationTracker(newProject, newState, this.CachedSkeletonReferences.Clone());
return new CompilationTracker(newProject, newState, this.SkeletonReferenceCache.Clone());
}
}

Expand Down Expand Up @@ -197,7 +197,7 @@ public ICompilationTracker FreezePartialStateWithTree(SolutionState solution, Do
this.ProjectState.Id,
metadataReferenceToProjectId);

return new CompilationTracker(inProgressProject, finalState, this.CachedSkeletonReferences.Clone());
return new CompilationTracker(inProgressProject, finalState, this.SkeletonReferenceCache.Clone());
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ private class GeneratedFileReplacingCompilationTracker : ICompilationTracker
[DisallowNull]
private Compilation? _compilationWithReplacement;

public CachedSkeletonReferences CachedSkeletonReferences { get; }
public SkeletonReferenceCache SkeletonReferenceCache { get; }

public GeneratedFileReplacingCompilationTracker(ICompilationTracker underlyingTracker, SourceGeneratedDocumentState replacementDocumentState)
{
_underlyingTracker = underlyingTracker;
_replacedGeneratedDocumentState = replacementDocumentState;
CachedSkeletonReferences = underlyingTracker.CachedSkeletonReferences.Clone();
SkeletonReferenceCache = underlyingTracker.SkeletonReferenceCache.Clone();
}

public ProjectState ProjectState => _underlyingTracker.ProjectState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ private interface ICompilationTracker
{
ProjectState ProjectState { get; }

CachedSkeletonReferences CachedSkeletonReferences { get; }
SkeletonReferenceCache SkeletonReferenceCache { get; }

/// <summary>
/// Returns <see langword="true"/> if this <see cref="Project"/>/<see cref="Compilation"/> could produce the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
Expand Down Expand Up @@ -43,7 +42,7 @@ internal partial class SolutionState
/// different semantics) will not leak backward to a prior <see cref="ProjectState"/>, causing it to see a view of the world
/// inapplicable to its current snapshot.
/// </summary>
private partial class CachedSkeletonReferences
private partial class SkeletonReferenceCache
{
/// <summary>
/// Mapping from compilation instance to metadata-references for it. This allows us to associate the same
Expand Down Expand Up @@ -79,12 +78,12 @@ private partial class CachedSkeletonReferences
/// </summary>
private SkeletonReferenceSet? _skeletonReferenceSet;

public CachedSkeletonReferences()
public SkeletonReferenceCache()
: this(version: null, skeletonReferenceSet: null)
{
}

private CachedSkeletonReferences(
private SkeletonReferenceCache(
VersionStamp? version,
SkeletonReferenceSet? skeletonReferenceSet)
{
Expand All @@ -93,20 +92,20 @@ private CachedSkeletonReferences(
}

/// <summary>
/// Produces a copy of the <see cref="CachedSkeletonReferences"/>, allowing forks of <see cref="ProjectState"/> to
/// Produces a copy of the <see cref="SkeletonReferenceCache"/>, allowing forks of <see cref="ProjectState"/> to
/// reuse <see cref="MetadataReference"/>s when their dependent semantic version matches ours. In the case where
/// the version is different, then the clone will attempt to make a new skeleton reference for that version. If it
/// succeeds, it will use that. If it fails however, it can still use our skeletons.
/// </summary>
public CachedSkeletonReferences Clone()
public SkeletonReferenceCache Clone()
{
lock (_stateGate)
{
// pass along the best version/reference-set we computed for ourselves. That way future ProjectStates
// can use this data if either the version changed, or they weren't able to build a skeleton for themselves.
// By passing along a copy we ensure that if they have a different version, they'll end up producing a new
// SkeletonReferenceSet where they'll store their own data in which will not affect prior ProjectStates.
return new CachedSkeletonReferences(_version, _skeletonReferenceSet);
return new SkeletonReferenceCache(_version, _skeletonReferenceSet);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1914,7 +1914,7 @@ public SolutionState WithFrozenSourceGeneratedDocument(SourceGeneratedDocumentId
workspace.LogTestMessage($"Looking for a cached skeleton assembly for {projectReference.ProjectId} before taking the lock...");

var properties = new MetadataReferenceProperties(aliases: projectReference.Aliases, embedInteropTypes: projectReference.EmbedInteropTypes);
return await tracker.CachedSkeletonReferences.GetOrBuildReferenceAsync(
return await tracker.SkeletonReferenceCache.GetOrBuildReferenceAsync(
tracker, this, properties, cancellationToken).ConfigureAwait(false);
}
}
Expand Down

0 comments on commit 8dae3c9

Please sign in to comment.