Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
4158203a
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
4158203a
编写于
9月 21, 2020
作者:
S
Shen Chen
提交者:
GitHub
9月 21, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #47812 from Cosifne/dev/shech/checkPathChars
Don't rename the file if the replacement text is invalid
上级
7e89bce3
3c851771
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
58 addition
and
7 deletion
+58
-7
src/EditorFeatures/Core.Wpf/InlineRename/Dashboard/DashboardViewModel.cs
...res/Core.Wpf/InlineRename/Dashboard/DashboardViewModel.cs
+25
-6
src/EditorFeatures/Test2/Rename/InlineRenameTests.vb
src/EditorFeatures/Test2/Rename/InlineRenameTests.vb
+32
-0
src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.Session.cs
...ortable/Rename/ConflictEngine/ConflictResolver.Session.cs
+1
-1
未找到文件。
src/EditorFeatures/Core.Wpf/InlineRename/Dashboard/DashboardViewModel.cs
浏览文件 @
4158203a
...
...
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Immutable
;
using
System.ComponentModel
;
using
System.Linq
;
...
...
@@ -31,6 +30,7 @@ internal class DashboardViewModel : INotifyPropertyChanged, IDisposable
private
bool
_defaultRenameInCommentsFlag
;
private
bool
_defaultRenameFileFlag
;
private
bool
_defaultPreviewChangesFlag
;
private
bool
_isReplacementTextValid
;
public
DashboardViewModel
(
InlineRenameSession
session
)
{
...
...
@@ -50,9 +50,9 @@ public DashboardViewModel(InlineRenameSession session)
_session
.
ReplacementsComputed
+=
OnReplacementsComputed
;
_session
.
ReplacementTextChanged
+=
OnReplacementTextChanged
;
// Set the flag to true by default if we're showing the option.
Use
// the property so we correctly update the session as well
DefaultRenameFileFlag
=
session
.
OptionSet
.
GetOption
(
RenameOptions
.
RenameFile
)
||
AllowFileRename
;
// Set the flag to true by default if we're showing the option.
_isReplacementTextValid
=
true
;
ComputeDefaultRenameFileFlag
()
;
}
public
event
PropertyChangedEventHandler
PropertyChanged
;
...
...
@@ -65,12 +65,31 @@ private void OnReferenceLocationsChanged(object sender, ImmutableArray<InlineRen
UpdateSearchText
(
totalSpansCount
,
totalFilesCount
);
}
private
void
OnIsReplacementTextValidChanged
(
bool
isReplacementTextValid
)
{
if
(
isReplacementTextValid
==
_isReplacementTextValid
)
{
return
;
}
_isReplacementTextValid
=
isReplacementTextValid
;
ComputeDefaultRenameFileFlag
();
NotifyPropertyChanged
(
nameof
(
AllowFileRename
));
}
private
void
ComputeDefaultRenameFileFlag
()
{
// If replacementText is invalid, we won't rename the file.
DefaultRenameFileFlag
=
_isReplacementTextValid
&&
(
_session
.
OptionSet
.
GetOption
(
RenameOptions
.
RenameFile
)
||
AllowFileRename
);
}
private
void
OnReplacementsComputed
(
object
sender
,
IInlineRenameReplacementInfo
result
)
{
var
session
=
(
InlineRenameSession
)
sender
;
_resolvableConflictCount
=
0
;
_unresolvableConflictCount
=
0
;
OnIsReplacementTextValidChanged
(
result
.
ReplacementTextValid
);
if
(
result
.
ReplacementTextValid
)
{
_errorText
=
null
;
...
...
@@ -154,7 +173,7 @@ private void UpdateSeverity()
public
DashboardSeverity
Severity
=>
_severity
;
public
bool
AllowFileRename
=>
_session
.
FileRenameInfo
==
InlineRenameFileRenameInfo
.
Allowed
;
public
bool
AllowFileRename
=>
_session
.
FileRenameInfo
==
InlineRenameFileRenameInfo
.
Allowed
&&
_isReplacementTextValid
;
public
bool
ShowFileRename
=>
_session
.
FileRenameInfo
!=
InlineRenameFileRenameInfo
.
NotAllowed
;
public
string
FileRenameString
=>
_session
.
FileRenameInfo
switch
{
...
...
src/EditorFeatures/Test2/Rename/InlineRenameTests.vb
浏览文件 @
4158203a
...
...
@@ -110,6 +110,38 @@ class C
End
Using
End
Function
<
WpfTheory
>
<
CombinatorialData
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Rename
)
>
<
WorkItem
(
46208
,
"https://github.com/dotnet/roslyn/issues/46208"
)
>
Public
Async
Function
RenameWithInvalidIdentifier
(
host
As
RenameTestHost
)
As
Task
Using
workspace
=
CreateWorkspaceWithWaiter
(
<
Workspace
>
<
Project
Language
=
"C#"
CommonReferences
=
"true"
>
<
Document
><
!
[
CDATA
[
class
[|
Test1
$$|]
{
}
]]
></
Document
>
</
Project
>
</
Workspace
>
,
host
)
Dim
options
=
workspace
.
CurrentSolution
.
Options
workspace
.
TryApplyChanges
(
workspace
.
CurrentSolution
.
WithOptions
(
options
.
WithChangedOption
(
RenameOptions
.
RenameFile
,
True
)))
Dim
session
=
StartSession
(
workspace
)
Dim
selectedSpan
=
workspace
.
DocumentWithCursor
.
CursorPosition
.
Value
Dim
textBuffer
=
workspace
.
Documents
.
Single
().
GetTextBuffer
()
' User could use copy & paste to enter invalid character
textBuffer
.
Insert
(
selectedSpan
,
"<>"
)
session
.
Commit
()
Await
VerifyTagsAreCorrect
(
workspace
,
"Test1<>"
)
VerifyFileName
(
workspace
,
"Test1"
)
End
Using
End
Function
<
WpfTheory
>
<
CombinatorialData
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Rename
)
>
<
WorkItem
(
22495
,
"https://github.com/dotnet/roslyn/issues/22495"
)
>
...
...
src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.Session.cs
浏览文件 @
4158203a
...
...
@@ -245,7 +245,7 @@ public async Task<MutableConflictResolution> ResolveConflictsAsync()
.
Select
(
l
=>
conflictResolution
.
OldSolution
.
GetDocument
(
l
.
SourceTree
))
.
Distinct
();
if
(
definitionDocuments
.
Count
()
==
1
)
if
(
definitionDocuments
.
Count
()
==
1
&&
_replacementTextValid
)
{
// At the moment, only single document renaming is allowed
conflictResolution
.
RenameDocumentToMatchNewSymbol
(
definitionDocuments
.
Single
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录