Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
52e26cdd
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,发现更多精彩内容 >>
未验证
提交
52e26cdd
编写于
3月 05, 2019
作者:
S
Sam Harwell
提交者:
GitHub
3月 05, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #33871 from sharwell/fix-close-file
Split CloseFile into CloseCodeFile and CloseDesignerFile
上级
4de954e2
2aae65ac
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
39 addition
and
25 deletion
+39
-25
src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpGoToDefinition.cs
...ationTest/IntegrationTests/CSharp/CSharpGoToDefinition.cs
+1
-1
src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpGoToImplementation.cs
...nTest/IntegrationTests/CSharp/CSharpGoToImplementation.cs
+1
-1
src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpWinForms.cs
...IntegrationTest/IntegrationTests/CSharp/CSharpWinForms.cs
+3
-3
src/VisualStudio/IntegrationTest/IntegrationTests/VisualBasic/BasicLineCommit.cs
...ationTest/IntegrationTests/VisualBasic/BasicLineCommit.cs
+2
-2
src/VisualStudio/IntegrationTest/IntegrationTests/VisualBasic/BasicWinForms.cs
...grationTest/IntegrationTests/VisualBasic/BasicWinForms.cs
+4
-4
src/VisualStudio/IntegrationTest/TestUtilities/InProcess/SolutionExplorer_InProc.cs
...onTest/TestUtilities/InProcess/SolutionExplorer_InProc.cs
+23
-12
src/VisualStudio/IntegrationTest/TestUtilities/OutOfProcess/SolutionExplorer_OutOfProc.cs
.../TestUtilities/OutOfProcess/SolutionExplorer_OutOfProc.cs
+5
-2
未找到文件。
src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpGoToDefinition.cs
浏览文件 @
52e26cdd
...
...
@@ -55,7 +55,7 @@ public void GoToDefinitionOpensProvisionalTabIfDocumentNotAlreadyOpen()
{
}
"
);
VisualStudio
.
SolutionExplorer
.
CloseFile
(
project
,
"FileDef.cs"
,
saveFile
:
true
);
VisualStudio
.
SolutionExplorer
.
Close
Code
File
(
project
,
"FileDef.cs"
,
saveFile
:
true
);
VisualStudio
.
SolutionExplorer
.
AddFile
(
project
,
"FileConsumer.cs"
);
VisualStudio
.
SolutionExplorer
.
OpenFile
(
project
,
"FileConsumer.cs"
);
VisualStudio
.
Editor
.
SetText
(
...
...
src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpGoToImplementation.cs
浏览文件 @
52e26cdd
...
...
@@ -52,7 +52,7 @@ public void GoToImplementationOpensProvisionalTabIfDocumentNotOpen()
{
}
"
);
VisualStudio
.
SolutionExplorer
.
CloseFile
(
project
,
"FileImplementation.cs"
,
saveFile
:
true
);
VisualStudio
.
SolutionExplorer
.
Close
Code
File
(
project
,
"FileImplementation.cs"
,
saveFile
:
true
);
VisualStudio
.
SolutionExplorer
.
AddFile
(
project
,
"FileInterface.cs"
);
VisualStudio
.
SolutionExplorer
.
OpenFile
(
project
,
"FileInterface.cs"
);
VisualStudio
.
Editor
.
SetText
(
...
...
src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpWinForms.cs
浏览文件 @
52e26cdd
...
...
@@ -39,7 +39,7 @@ public void ChangeControlProperty()
VisualStudio
.
SolutionExplorer
.
OpenFileWithDesigner
(
project
,
"Form1.cs"
);
VisualStudio
.
Editor
.
AddWinFormButton
(
"SomeButton"
);
VisualStudio
.
Editor
.
EditWinFormButtonProperty
(
buttonName
:
"SomeButton"
,
propertyName
:
"Text"
,
propertyValue
:
"NewButtonText"
);
VisualStudio
.
SolutionExplorer
.
CloseFile
(
project
,
"Form1.cs"
,
saveFile
:
true
);
VisualStudio
.
SolutionExplorer
.
Close
Designer
File
(
project
,
"Form1.cs"
,
saveFile
:
true
);
VisualStudio
.
SolutionExplorer
.
OpenFile
(
project
,
"Form1.Designer.cs"
);
var
actualText
=
VisualStudio
.
Editor
.
GetText
();
Assert
.
Contains
(
@"this.SomeButton.Text = ""NewButtonText"""
,
actualText
);
...
...
@@ -55,7 +55,7 @@ public void ChangeControlPropertyInCode()
var
expectedPropertyValue
=
"ButtonTextGoesHere"
;
var
actualPropertyValue
=
VisualStudio
.
Editor
.
GetWinFormButtonPropertyValue
(
buttonName
:
"SomeButton"
,
propertyName
:
"Text"
);
Assert
.
Equal
(
expectedPropertyValue
,
actualPropertyValue
);
VisualStudio
.
SolutionExplorer
.
CloseFile
(
project
,
"Form1.cs"
,
saveFile
:
true
);
VisualStudio
.
SolutionExplorer
.
Close
Designer
File
(
project
,
"Form1.cs"
,
saveFile
:
true
);
// Change the control's text in designer.cs code
VisualStudio
.
SolutionExplorer
.
OpenFile
(
project
,
"Form1.Designer.cs"
);
// Verify that the control's property was set correctly. The following text should appear in InitializeComponent().
...
...
@@ -64,7 +64,7 @@ public void ChangeControlPropertyInCode()
// Replace text property with something else
VisualStudio
.
Editor
.
SelectTextInCurrentDocument
(
@"this.SomeButton.Text = ""ButtonTextGoesHere"";"
);
VisualStudio
.
Editor
.
SendKeys
(
@"this.SomeButton.Text = ""GibberishText"";"
);
VisualStudio
.
SolutionExplorer
.
CloseFile
(
project
,
"Form1.Designer.cs"
,
saveFile
:
true
);
VisualStudio
.
SolutionExplorer
.
Close
Code
File
(
project
,
"Form1.Designer.cs"
,
saveFile
:
true
);
// Verify that the control text has changed in the designer
VisualStudio
.
SolutionExplorer
.
OpenFileWithDesigner
(
project
,
"Form1.cs"
);
expectedPropertyValue
=
"GibberishText"
;
...
...
src/VisualStudio/IntegrationTest/IntegrationTests/VisualBasic/BasicLineCommit.cs
浏览文件 @
52e26cdd
...
...
@@ -107,7 +107,7 @@ End Sub
VisualStudio
.
SolutionExplorer
.
AddFile
(
new
ProjName
(
ProjectName
),
"TestZ.vb"
,
open
:
true
);
// Cause focus lost
VisualStudio
.
SolutionExplorer
.
OpenFile
(
new
ProjName
(
ProjectName
),
"TestZ.vb"
);
// Work around https://github.com/dotnet/roslyn/issues/18488
VisualStudio
.
Editor
.
SendKeys
(
" "
);
VisualStudio
.
SolutionExplorer
.
CloseFile
(
new
ProjName
(
ProjectName
),
"TestZ.vb"
,
saveFile
:
false
);
VisualStudio
.
SolutionExplorer
.
Close
Code
File
(
new
ProjName
(
ProjectName
),
"TestZ.vb"
,
saveFile
:
false
);
VisualStudio
.
Editor
.
Verify
.
TextContains
(
@"
Sub M()
End Sub
...
...
@@ -130,7 +130,7 @@ End Sub
VisualStudio
.
SolutionExplorer
.
AddFile
(
new
ProjName
(
ProjectName
),
"TestZ.vb"
,
open
:
true
);
// Cause focus lost
VisualStudio
.
SolutionExplorer
.
OpenFile
(
new
ProjName
(
ProjectName
),
"TestZ.vb"
);
// Work around https://github.com/dotnet/roslyn/issues/18488
VisualStudio
.
Editor
.
SendKeys
(
" "
);
VisualStudio
.
SolutionExplorer
.
CloseFile
(
new
ProjName
(
ProjectName
),
"TestZ.vb"
,
saveFile
:
false
);
VisualStudio
.
SolutionExplorer
.
Close
Code
File
(
new
ProjName
(
ProjectName
),
"TestZ.vb"
,
saveFile
:
false
);
VisualStudio
.
Editor
.
Verify
.
TextContains
(
@"
Sub M()
End Sub
...
...
src/VisualStudio/IntegrationTest/IntegrationTests/VisualBasic/BasicWinForms.cs
浏览文件 @
52e26cdd
...
...
@@ -55,7 +55,7 @@ public void AddControl()
var
project
=
new
ProjectUtils
.
Project
(
ProjectName
);
VisualStudio
.
SolutionExplorer
.
OpenFileWithDesigner
(
project
,
"Form1.vb"
);
VisualStudio
.
Editor
.
AddWinFormButton
(
"SomeButton"
);
VisualStudio
.
SolutionExplorer
.
CloseFile
(
project
,
"Form1.vb"
,
saveFile
:
true
);
VisualStudio
.
SolutionExplorer
.
Close
Designer
File
(
project
,
"Form1.vb"
,
saveFile
:
true
);
VisualStudio
.
SolutionExplorer
.
OpenFile
(
project
,
"Form1.Designer.vb"
);
var
actualText
=
VisualStudio
.
Editor
.
GetText
();
Assert
.
Contains
(
@"Me.SomeButton.Name = ""SomeButton"""
,
actualText
);
...
...
@@ -69,7 +69,7 @@ public void ChangeControlProperty()
VisualStudio
.
SolutionExplorer
.
OpenFileWithDesigner
(
project
,
"Form1.vb"
);
VisualStudio
.
Editor
.
AddWinFormButton
(
"SomeButton"
);
VisualStudio
.
Editor
.
EditWinFormButtonProperty
(
buttonName
:
"SomeButton"
,
propertyName
:
"Text"
,
propertyValue
:
"NewButtonText"
);
VisualStudio
.
SolutionExplorer
.
CloseFile
(
project
,
"Form1.vb"
,
saveFile
:
true
);
VisualStudio
.
SolutionExplorer
.
Close
Designer
File
(
project
,
"Form1.vb"
,
saveFile
:
true
);
VisualStudio
.
SolutionExplorer
.
OpenFile
(
project
,
"Form1.Designer.vb"
);
var
actualText
=
VisualStudio
.
Editor
.
GetText
();
Assert
.
Contains
(
@"Me.SomeButton.Text = ""NewButtonText"""
,
actualText
);
...
...
@@ -85,7 +85,7 @@ public void ChangeControlPropertyInCode()
var
expectedPropertyValue
=
"ButtonTextGoesHere"
;
var
actualPropertyValue
=
VisualStudio
.
Editor
.
GetWinFormButtonPropertyValue
(
buttonName
:
"SomeButton"
,
propertyName
:
"Text"
);
Assert
.
Equal
(
expectedPropertyValue
,
actualPropertyValue
);
VisualStudio
.
SolutionExplorer
.
CloseFile
(
project
,
"Form1.vb"
,
saveFile
:
true
);
VisualStudio
.
SolutionExplorer
.
Close
Designer
File
(
project
,
"Form1.vb"
,
saveFile
:
true
);
// Change the control's text in designer.vb code
VisualStudio
.
SolutionExplorer
.
OpenFile
(
project
,
"Form1.Designer.vb"
);
// Verify that the control's property was set correctly. The following text should appear in InitializeComponent().
...
...
@@ -94,7 +94,7 @@ public void ChangeControlPropertyInCode()
// Replace text property with something else
VisualStudio
.
Editor
.
SelectTextInCurrentDocument
(
@"Me.SomeButton.Text = ""ButtonTextGoesHere"""
);
VisualStudio
.
Editor
.
SendKeys
(
@"Me.SomeButton.Text = ""GibberishText"""
);
VisualStudio
.
SolutionExplorer
.
CloseFile
(
project
,
"Form1.Designer.vb"
,
saveFile
:
true
);
VisualStudio
.
SolutionExplorer
.
Close
Code
File
(
project
,
"Form1.Designer.vb"
,
saveFile
:
true
);
// Verify that the control text has changed in the designer
VisualStudio
.
SolutionExplorer
.
OpenFileWithDesigner
(
project
,
"Form1.vb"
);
expectedPropertyValue
=
"GibberishText"
;
...
...
src/VisualStudio/IntegrationTest/TestUtilities/InProcess/SolutionExplorer_InProc.cs
浏览文件 @
52e26cdd
...
...
@@ -584,7 +584,7 @@ void SetText(string text)
OpenFile
(
projectName
,
fileName
);
SetText
(
contents
??
string
.
Empty
);
CloseFile
(
projectName
,
fileName
,
saveFile
:
true
);
Close
Code
File
(
projectName
,
fileName
,
saveFile
:
true
);
if
(
open
)
{
OpenFile
(
projectName
,
fileName
);
...
...
@@ -888,25 +888,36 @@ public void OpenFile(string projectName, string relativeFilePath)
ErrorHandler
.
ThrowOnFailure
(
textManager
.
NavigateToLineAndColumn
(
textLines
,
VSConstants
.
LOGVIEWID
.
Code_guid
,
line
,
column
,
line
,
column
));
}
public
void
CloseFile
(
string
projectName
,
string
relativeFilePath
,
bool
saveFile
)
public
void
Close
Designer
File
(
string
projectName
,
string
relativeFilePath
,
bool
saveFile
)
{
var
document
=
GetOpenDocument
(
projectName
,
relativeFilePath
);
if
(
saveFile
)
{
SaveFileWithExtraValidation
(
document
);
document
.
Close
(
EnvDTE
.
vsSaveChanges
.
vsSaveChangesYes
);
}
else
CloseFile
(
projectName
,
relativeFilePath
,
VSConstants
.
LOGVIEWID
.
Designer_guid
,
saveFile
);
}
public
void
CloseCodeFile
(
string
projectName
,
string
relativeFilePath
,
bool
saveFile
)
{
CloseFile
(
projectName
,
relativeFilePath
,
VSConstants
.
LOGVIEWID
.
Code_guid
,
saveFile
);
}
private
void
CloseFile
(
string
projectName
,
string
relativeFilePath
,
Guid
logicalView
,
bool
saveFile
)
{
InvokeOnUIThread
(()
=>
{
document
.
Close
(
EnvDTE
.
vsSaveChanges
.
vsSaveChangesNo
);
}
var
filePath
=
GetAbsolutePathForProjectRelativeFilePath
(
projectName
,
relativeFilePath
);
if
(!
VsShellUtilities
.
IsDocumentOpen
(
ServiceProvider
.
GlobalProvider
,
filePath
,
logicalView
,
out
_
,
out
_
,
out
var
windowFrame
))
{
throw
new
InvalidOperationException
(
$"File '
{
filePath
}
' is not open in logical view '
{
logicalView
}
'"
);
}
var
frameClose
=
saveFile
?
__FRAMECLOSE
.
FRAMECLOSE_SaveIfDirty
:
__FRAMECLOSE
.
FRAMECLOSE_NoSave
;
ErrorHandler
.
ThrowOnFailure
(
windowFrame
.
CloseFrame
((
uint
)
frameClose
));
});
}
private
EnvDTE
.
Document
GetOpenDocument
(
string
projectName
,
string
relativeFilePath
)
{
var
filePath
=
GetAbsolutePathForProjectRelativeFilePath
(
projectName
,
relativeFilePath
);
var
documents
=
GetDTE
().
Documents
.
Cast
<
EnvDTE
.
Document
>();
var
document
=
documents
.
First
OrDefault
(
d
=>
d
.
FullName
==
filePath
);
var
document
=
documents
.
Single
OrDefault
(
d
=>
d
.
FullName
==
filePath
);
if
(
document
==
null
)
{
...
...
src/VisualStudio/IntegrationTest/TestUtilities/OutOfProcess/SolutionExplorer_OutOfProc.cs
浏览文件 @
52e26cdd
...
...
@@ -128,8 +128,11 @@ public void RenameFileViaDTE(ProjectUtils.Project project, string oldFileName, s
_instance
.
Workspace
.
WaitForAsyncOperations
(
FeatureAttribute
.
Workspace
);
}
public
void
CloseFile
(
ProjectUtils
.
Project
project
,
string
fileName
,
bool
saveFile
)
=>
_inProc
.
CloseFile
(
project
.
Name
,
fileName
,
saveFile
);
public
void
CloseDesignerFile
(
ProjectUtils
.
Project
project
,
string
fileName
,
bool
saveFile
)
=>
_inProc
.
CloseDesignerFile
(
project
.
Name
,
fileName
,
saveFile
);
public
void
CloseCodeFile
(
ProjectUtils
.
Project
project
,
string
fileName
,
bool
saveFile
)
=>
_inProc
.
CloseCodeFile
(
project
.
Name
,
fileName
,
saveFile
);
public
void
SaveFile
(
ProjectUtils
.
Project
project
,
string
fileName
)
=>
_inProc
.
SaveFile
(
project
.
Name
,
fileName
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录