未验证 提交 1bb887d9 编写于 作者: J Jason Malinowski 提交者: GitHub

Merge pull request #38841 from CyrusNajmabadi/renameFSharp

Fix crash that would happen when renaming in mixed f#/c# project.
......@@ -7108,5 +7108,32 @@ class C
End Sub
#End Region
<WpfFact>
<WorkItem(28474, "https://github.com/dotnet/roslyn/issues/28474")>
<Trait(Traits.Feature, Traits.Features.Rename)>
Public Sub HandleProjectsWithoutCompilations()
Using result = RenameEngineResult.Create(_outputHelper,
<Workspace>
<Project Language="C#" AssemblyName="CSharpProject" CommonReferences="true">
<Document>
public interface IGoo
{
void [|$$Goo|]();
}
public class C : IGoo
{
public void [|Goo|]() {}
}
</Document>
</Project>
<Project Language="NoCompilation" CommonReferences="false">
<ProjectReference>CSharpProject</ProjectReference>
<Document>
// a no-compilation document
</Document>
</Project>
</Workspace>, renameTo:="Cat")
End Using
End Sub
End Class
End Namespace
......@@ -331,6 +331,7 @@ bool metadataTypeMatches(SymbolAndProjectIdSet s, INamedTypeSymbol t)
// cache churn we could cause creating all those compilations.
foreach (var project in orderedProjectsToExamine)
{
Debug.Assert(project.SupportsCompilation);
await FindTypesInProjectAsync(
searchInMetadata, result,
currentMetadataTypes, currentSourceAndMetadataTypes,
......@@ -364,6 +365,8 @@ bool metadataTypeMatches(SymbolAndProjectIdSet s, INamedTypeSymbol t)
bool transitive,
CancellationToken cancellationToken)
{
Debug.Assert(project.SupportsCompilation);
// First see what derived metadata types we might find in this project.
// This is only necessary if we started with a metadata type.
if (searchInMetadata)
......@@ -522,7 +525,7 @@ bool metadataTypeMatches(SymbolAndProjectIdSet s, INamedTypeSymbol t)
// /
// └
// E
// and we're passed in 'B, C, E' as hte project to search, then this set
// and we're passed in 'B, C, E' as the project to search, then this set
// will be A, B, C, E.
var allProjectsThatTheseProjectsDependOn = projects
.SelectMany(p => dependencyGraph.GetProjectsThatThisProjectTransitivelyDependsOn(p.Id))
......@@ -537,8 +540,11 @@ bool metadataTypeMatches(SymbolAndProjectIdSet s, INamedTypeSymbol t)
// any information that would affect the result in the projects we are asked to search
// within.
// Finally, because we're searching metadata and source symbols, this needs to be a project
// that actually supports compilations.
return projectsThatCouldReferenceType.Intersect(allProjectsThatTheseProjectsDependOn)
.Select(solution.GetProject)
.Where(p => p.SupportsCompilation)
.ToList();
}
......@@ -549,12 +555,9 @@ bool metadataTypeMatches(SymbolAndProjectIdSet s, INamedTypeSymbol t)
SymbolAndProjectIdSet result,
CancellationToken cancellationToken)
{
if (metadataTypes.Count == 0)
{
return;
}
Debug.Assert(project.SupportsCompilation);
if (!project.SupportsCompilation)
if (metadataTypes.Count == 0)
{
return;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册