未验证 提交 535cb0ab 编写于 作者: A Andrew Hall 提交者: GitHub

Check that the document can be changed for a file rename (#38612)

* Check that the document can be changed for a file rename

* Add test

* Remove extra line
......@@ -244,7 +244,8 @@ public bool TryOnAfterGlobalSymbolRenamed(Workspace workspace, IEnumerable<Docum
public InlineRenameFileRenameInfo GetFileRenameInfo()
{
if (RenameSymbol.Kind == SymbolKind.NamedType)
if (RenameSymbol.Kind == SymbolKind.NamedType &&
_document.Project.Solution.Workspace.CanApplyChange(ApplyChangesKind.ChangeDocumentInfo))
{
if (RenameSymbol.Locations.Length > 1)
{
......
......@@ -1940,5 +1940,30 @@ End Class
Assert.Equal(InlineRenameFileRenameInfo.NotAllowed, session.FileRenameInfo)
End Using
End Sub
<WpfFact>
<Trait(Traits.Feature, Traits.Features.Rename)>
Public Sub VerifyFileRenameNotAllowedForLinkedFiles()
Using workspace = CreateWorkspaceWithWaiter(
<Workspace>
<Project Language="C#" CommonReferences="true" AssemblyName="CSProj" PreprocessorSymbols="Proj1">
<Document FilePath="C.cs"><![CDATA[public class [|$$C|] { } // [|C|]]]></Document>
</Project>
<Project Language="C#" CommonReferences="true" PreprocessorSymbols="Proj2">
<Document IsLinkFile="true" LinkAssemblyName="CSProj" LinkFilePath="C.cs"/>
</Project>
</Workspace>)
' Disable document changes to make sure file rename is not supported.
' Linked workspace files will report that applying changes to document
' info is not allowed; this is intended to mimic that behavior
' and make sure inline rename works as intended.
workspace.CanApplyChangeDocument = False
Dim session = StartSession(workspace)
Assert.Equal(InlineRenameFileRenameInfo.NotAllowed, session.FileRenameInfo)
End Using
End Sub
End Class
End Namespace
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册