Skip to content

Commit 99014d0

Browse files
Merge pull request #56073 from jasonmalinowski/obsolete-support-for-isolated-solutions
Obsolete Solution.GetIsolatedSolution
2 parents 6c8a303 + 71d491d commit 99014d0

File tree

5 files changed

+7
-45
lines changed

5 files changed

+7
-45
lines changed

src/Workspaces/Core/Portable/Workspace/Solution/Solution.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,16 +1703,13 @@ internal Solution WithNewWorkspace(Workspace workspace, int workspaceVersion)
17031703
}
17041704

17051705
/// <summary>
1706-
/// Gets a copy of the solution isolated from the original so that they do not share computed state.
1707-
///
1708-
/// Use isolated solutions when doing operations that are likely to access a lot of text,
1709-
/// syntax trees or compilations that are unlikely to be needed again after the operation is done.
1710-
/// When the isolated solution is reclaimed so will the computed state.
1706+
/// Formerly, returned a copy of the solution isolated from the original so that they do not share computed state. It now does nothing.
17111707
/// </summary>
1708+
[Obsolete("This method no longer produces a Solution that does not share state and is no longer necessary to call.", error: false)]
17121709
public Solution GetIsolatedSolution()
17131710
{
1714-
var newState = _state.GetIsolatedSolution();
1715-
return new Solution(newState);
1711+
// To maintain compat, just return ourself, which will be functionally identical.
1712+
return this;
17161713
}
17171714

17181715
/// <summary>

src/Workspaces/Core/Portable/Workspace/Solution/SolutionState.CompilationTracker.cs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -114,19 +114,13 @@ public bool ContainsAssemblyOrModuleOrDynamic(ISymbol symbol, bool primary)
114114
public ICompilationTracker Fork(
115115
ProjectState newProject,
116116
CompilationAndGeneratorDriverTranslationAction? translate = null,
117-
bool clone = false,
118117
CancellationToken cancellationToken = default)
119118
{
120119
var state = ReadState();
121120

122121
var baseCompilation = state.CompilationWithoutGeneratedDocuments?.GetValueOrNull(cancellationToken);
123122
if (baseCompilation != null)
124123
{
125-
// We have some pre-calculated state to incrementally update
126-
var newInProgressCompilation = clone
127-
? baseCompilation.Clone()
128-
: baseCompilation;
129-
130124
var intermediateProjects = state is InProgressState inProgressState
131125
? inProgressState.IntermediateProjects
132126
: ImmutableArray.Create<(ProjectState oldState, CompilationAndGeneratorDriverTranslationAction action)>();
@@ -155,7 +149,7 @@ public ICompilationTracker Fork(
155149
}
156150
}
157151

158-
var newState = State.Create(newInProgressCompilation, state.GeneratedDocuments, state.GeneratorDriver, state.FinalCompilationWithGeneratedDocuments?.GetValueOrNull(cancellationToken), intermediateProjects);
152+
var newState = State.Create(baseCompilation, state.GeneratedDocuments, state.GeneratorDriver, state.FinalCompilationWithGeneratedDocuments?.GetValueOrNull(cancellationToken), intermediateProjects);
159153

160154
return new CompilationTracker(newProject, newState);
161155
}
@@ -177,12 +171,6 @@ public ICompilationTracker Fork(
177171
return new CompilationTracker(newProject);
178172
}
179173

180-
/// <summary>
181-
/// Creates a fork with the same final project.
182-
/// </summary>
183-
public ICompilationTracker Clone()
184-
=> this.Fork(this.ProjectState, clone: true);
185-
186174
public ICompilationTracker FreezePartialStateWithTree(SolutionState solution, DocumentState docState, SyntaxTree tree, CancellationToken cancellationToken)
187175
{
188176
GetPartialCompilationState(

src/Workspaces/Core/Portable/Workspace/Solution/SolutionState.GeneratedFileReplacingCompilationTracker.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@ public GeneratedFileReplacingCompilationTracker(ICompilationTracker underlyingTr
4141

4242
public ProjectState ProjectState => _underlyingTracker.ProjectState;
4343

44-
public ICompilationTracker Clone()
45-
{
46-
return new GeneratedFileReplacingCompilationTracker(_underlyingTracker.Clone(), _replacedGeneratedDocumentState);
47-
}
48-
4944
public bool ContainsAssemblyOrModuleOrDynamic(ISymbol symbol, bool primary)
5045
{
5146
if (_compilationWithReplacement == null)
@@ -75,7 +70,7 @@ public bool ContainsAssemblyOrModuleOrDynamic(ISymbol symbol, bool primary)
7570
throw new NotImplementedException();
7671
}
7772

78-
public ICompilationTracker Fork(ProjectState newProject, CompilationAndGeneratorDriverTranslationAction? translate = null, bool clone = false, CancellationToken cancellationToken = default)
73+
public ICompilationTracker Fork(ProjectState newProject, CompilationAndGeneratorDriverTranslationAction? translate = null, CancellationToken cancellationToken = default)
7974
{
8075
// TODO: This only needs to be implemented if a feature that operates from a source generated file then makes
8176
// further mutations to that project, which isn't needed for now. This will be need to be fixed up when we complete

src/Workspaces/Core/Portable/Workspace/Solution/SolutionState.ICompilationTracker.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ private interface ICompilationTracker
3030
bool HasCompilation { get; }
3131
ProjectState ProjectState { get; }
3232

33-
ICompilationTracker Clone();
34-
3533
/// <summary>
3634
/// Returns <see langword="true"/> if this <see cref="Project"/>/<see cref="Compilation"/> could produce the
3735
/// given <paramref name="symbol"/>. The symbol must be a <see cref="IAssemblySymbol"/>, <see
@@ -49,7 +47,7 @@ private interface ICompilationTracker
4947
bool ContainsAssemblyOrModuleOrDynamic(ISymbol symbol, bool primary);
5048
bool? ContainsSymbolsWithNameFromDeclarationOnlyCompilation(Func<string, bool> predicate, SymbolFilter filter, CancellationToken cancellationToken);
5149
bool? ContainsSymbolsWithNameFromDeclarationOnlyCompilation(string name, SymbolFilter filter, CancellationToken cancellationToken);
52-
ICompilationTracker Fork(ProjectState newProject, CompilationAndGeneratorDriverTranslationAction? translate = null, bool clone = false, CancellationToken cancellationToken = default);
50+
ICompilationTracker Fork(ProjectState newProject, CompilationAndGeneratorDriverTranslationAction? translate = null, CancellationToken cancellationToken = default);
5351
ICompilationTracker FreezePartialStateWithTree(SolutionState solution, DocumentState docState, SyntaxTree tree, CancellationToken cancellationToken);
5452
Task<Compilation> GetCompilationAsync(SolutionState solution, CancellationToken cancellationToken);
5553
Task<VersionStamp> GetDependentSemanticVersionAsync(SolutionState solution, CancellationToken cancellationToken);

src/Workspaces/Core/Portable/Workspace/Solution/SolutionState.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,22 +1621,6 @@ bool CanReuse(ProjectId id)
16211621
}
16221622
}
16231623

1624-
/// <summary>
1625-
/// Gets a copy of the solution isolated from the original so that they do not share computed state.
1626-
///
1627-
/// Use isolated solutions when doing operations that are likely to access a lot of text,
1628-
/// syntax trees or compilations that are unlikely to be needed again after the operation is done.
1629-
/// When the isolated solution is reclaimed so will the computed state.
1630-
/// </summary>
1631-
public SolutionState GetIsolatedSolution()
1632-
{
1633-
var forkedMap = ImmutableDictionary.CreateRange(
1634-
_projectIdToTrackerMap.Where(kvp => kvp.Value.HasCompilation)
1635-
.Select(kvp => KeyValuePairUtil.Create(kvp.Key, kvp.Value.Clone())));
1636-
1637-
return this.Branch(projectIdToTrackerMap: forkedMap);
1638-
}
1639-
16401624
public SolutionState WithOptions(SerializableOptionSet options)
16411625
=> Branch(options: options);
16421626

0 commit comments

Comments
 (0)