Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ protected CompilationTrackerState(
CompilationWithoutGeneratedDocuments = compilationWithoutGeneratedDocuments;
GeneratorInfo = generatorInfo;

// When in the frozen state, all documents must be final. We never want to run generators for frozen
// states as the point is to be fast (while potentially incomplete).
if (IsFrozen)
Contract.ThrowIfFalse(generatorInfo.DocumentsAreFinal);

#if DEBUG
// As a sanity check, we should never see the generated trees inside of the compilation that should
// not have generated trees.
Expand Down Expand Up @@ -96,7 +91,7 @@ private InProgressState(
Compilation compilationWithoutGeneratedDocuments,
CompilationTrackerGeneratorInfo generatorInfo,
Compilation? staleCompilationWithGeneratedDocuments,
ImmutableList<(ProjectState state, CompilationAndGeneratorDriverTranslationAction action)> pendingTranslationSteps)
ImmutableList<(ProjectState oldState, CompilationAndGeneratorDriverTranslationAction action)> pendingTranslationSteps)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

naming for consistency.

: base(isFrozen,
compilationWithoutGeneratedDocuments,
generatorInfo)
Expand All @@ -113,15 +108,10 @@ public static InProgressState Create(
Compilation compilationWithoutGeneratedDocuments,
CompilationTrackerGeneratorInfo generatorInfo,
Compilation? staleCompilationWithGeneratedDocuments,
ImmutableList<(ProjectState state, CompilationAndGeneratorDriverTranslationAction action)> pendingTranslationSteps)
ImmutableList<(ProjectState oldState, CompilationAndGeneratorDriverTranslationAction action)> pendingTranslationSteps)
{
Contract.ThrowIfTrue(pendingTranslationSteps is null);

// If we're not frozen, transition back to the non-final state as we def want to rerun generators
// for either of these non-final states.
if (!isFrozen)
generatorInfo = generatorInfo with { DocumentsAreFinal = false };

// If we don't have any intermediate projects to process, just initialize our
// DeclarationState now. We'll pass false for generatedDocumentsAreFinal because this is being called
// if our referenced projects are changing, so we'll have to rerun to consume changes.
Expand Down Expand Up @@ -175,9 +165,11 @@ private FinalCompilationTrackerState(
UnrootedSymbolSet unrootedSymbolSet)
: base(isFrozen, compilationWithoutGeneratedDocuments, generatorInfo)
{
Contract.ThrowIfFalse(generatorInfo.DocumentsAreFinal);
Contract.ThrowIfNull(finalCompilationWithGeneratedDocuments);
HasSuccessfullyLoaded = hasSuccessfullyLoaded;

// As a policy, all partial-state projects are said to have incomplete references, since the
// state has no guarantees.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved from a different location here, so that we're consistent on what this bit means wrt frozen states.

HasSuccessfullyLoaded = hasSuccessfullyLoaded && !isFrozen;
FinalCompilationWithGeneratedDocuments = finalCompilationWithGeneratedDocuments;
UnrootedSymbolSet = unrootedSymbolSet;

Expand All @@ -201,8 +193,6 @@ public static FinalCompilationTrackerState Create(
ProjectId projectId,
Dictionary<MetadataReference, ProjectId>? metadataReferenceToProjectId)
{
Contract.ThrowIfFalse(generatorInfo.DocumentsAreFinal);

// Keep track of information about symbols from this Compilation. This will help support other APIs
// the solution exposes that allows the user to map back from symbols to project information.

Expand All @@ -218,6 +208,14 @@ public static FinalCompilationTrackerState Create(
unrootedSymbolSet);
}

public FinalCompilationTrackerState WithIsFrozen()
=> new(isFrozen: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new

no check to return this if already frozen?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair. i can do that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put into: #72111

FinalCompilationWithGeneratedDocuments,
CompilationWithoutGeneratedDocuments,
HasSuccessfullyLoaded,
GeneratorInfo,
UnrootedSymbolSet);

private static void RecordAssemblySymbols(ProjectId projectId, Compilation compilation, Dictionary<MetadataReference, ProjectId>? metadataReferenceToProjectId)
{
RecordSourceOfAssemblySymbol(compilation.Assembly, projectId);
Expand Down
Loading