Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
651452ee
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,发现更多精彩内容 >>
提交
651452ee
编写于
7月 16, 2019
作者:
J
Jason Malinowski
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add nullable annotations to the "extract interface" dialog
Fixes
https://github.com/dotnet/roslyn/issues/37176
上级
0a6d482a
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
32 addition
and
56 deletion
+32
-56
src/VisualStudio/Core/Def/Implementation/ExtractInterface/ExtractInterfaceDialog.xaml
...plementation/ExtractInterface/ExtractInterfaceDialog.xaml
+3
-3
src/VisualStudio/Core/Def/Implementation/ExtractInterface/ExtractInterfaceDialogViewModel.cs
...ation/ExtractInterface/ExtractInterfaceDialogViewModel.cs
+3
-42
src/VisualStudio/Core/Def/Implementation/ExtractInterface/VisualStudioExtractInterfaceOptionsService.cs
...ctInterface/VisualStudioExtractInterfaceOptionsService.cs
+1
-1
src/VisualStudio/Core/Test/ExtractInterface/ExtractInterfaceViewModelTests.vb
...e/Test/ExtractInterface/ExtractInterfaceViewModelTests.vb
+23
-8
src/VisualStudio/IntegrationTest/TestUtilities/InProcess/ExtractInterfaceDialog_InProc.cs
.../TestUtilities/InProcess/ExtractInterfaceDialog_InProc.cs
+2
-2
未找到文件。
src/VisualStudio/Core/Def/Implementation/ExtractInterface/ExtractInterfaceDialog.xaml
浏览文件 @
651452ee
...
...
@@ -136,17 +136,17 @@
<DataTemplate>
<StackPanel Orientation="Horizontal">
<CheckBox x:Uid="SelectableMemberCheckBox"
AutomationProperties.Name="{Binding
Member
AutomationText}"
AutomationProperties.Name="{Binding
Symbol
AutomationText}"
IsChecked="{Binding IsChecked, Mode=TwoWay}"
Width="Auto"
Focusable="False"
AutomationProperties.AutomationId="{Binding
Member
Name}">
AutomationProperties.AutomationId="{Binding
Symbol
Name}">
</CheckBox>
<Image x:Uid="SelectableMemberGlyph"
Margin="8,0,0,0"
Source="{Binding Glyph}"/>
<TextBlock x:Uid="SelectableMemberName"
Text="{Binding
Member
Name}"/>
Text="{Binding
Symbol
Name}"/>
</StackPanel>
</DataTemplate>
</u:AutomationDelegatingListView.ItemTemplate>
...
...
src/VisualStudio/Core/Def/Implementation/ExtractInterface/ExtractInterfaceDialogViewModel.cs
浏览文件 @
651452ee
...
...
@@ -4,15 +4,11 @@
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
using
System.Windows.Media
;
using
Microsoft.CodeAnalysis
;
using
Microsoft.CodeAnalysis.Editor.Shared.Extensions
;
using
Microsoft.CodeAnalysis.LanguageServices
;
using
Microsoft.CodeAnalysis.Notification
;
using
Microsoft.CodeAnalysis.Shared.Extensions
;
using
Microsoft.VisualStudio.Language.Intellisense
;
using
Microsoft.VisualStudio.LanguageServices.Implementation.Utilities
;
using
Microsoft.VisualStudio.LanguageServices.Utilities
;
using
Roslyn.Utilities
;
namespace
Microsoft.VisualStudio.LanguageServices.Implementation.ExtractInterface
...
...
@@ -55,7 +51,7 @@ internal class ExtractInterfaceDialogViewModel : AbstractNotifyPropertyChanged
_generatedNameTypeParameterSuffix
=
generatedNameTypeParameterSuffix
;
_languageName
=
languageName
;
MemberContainers
=
extractableMembers
.
Select
(
m
=>
new
MemberSymbolViewModel
(
m
,
glyphService
)).
OrderBy
(
s
=>
s
.
Member
Name
).
ToList
();
MemberContainers
=
extractableMembers
.
Select
(
m
=>
new
MemberSymbolViewModel
(
m
,
glyphService
)).
OrderBy
(
s
=>
s
.
Symbol
Name
).
ToList
();
}
internal
bool
TrySubmit
()
...
...
@@ -173,45 +169,10 @@ public InterfaceDestination Destination
public
bool
FileNameEnabled
=>
Destination
==
InterfaceDestination
.
NewFile
;
internal
class
MemberSymbolViewModel
:
AbstractNotifyPropertyChanged
internal
class
MemberSymbolViewModel
:
SymbolViewModel
<
ISymbol
>
{
private
readonly
IGlyphService
_glyphService
;
public
ISymbol
MemberSymbol
{
get
;
}
private
static
readonly
SymbolDisplayFormat
s_memberDisplayFormat
=
new
SymbolDisplayFormat
(
genericsOptions
:
SymbolDisplayGenericsOptions
.
IncludeTypeParameters
,
memberOptions
:
SymbolDisplayMemberOptions
.
IncludeParameters
,
parameterOptions
:
SymbolDisplayParameterOptions
.
IncludeType
|
SymbolDisplayParameterOptions
.
IncludeParamsRefOut
|
SymbolDisplayParameterOptions
.
IncludeOptionalBrackets
,
miscellaneousOptions
:
SymbolDisplayMiscellaneousOptions
.
EscapeKeywordIdentifiers
|
SymbolDisplayMiscellaneousOptions
.
UseSpecialTypes
);
public
MemberSymbolViewModel
(
ISymbol
symbol
,
IGlyphService
glyphService
)
{
MemberSymbol
=
symbol
;
_glyphService
=
glyphService
;
_isChecked
=
true
;
}
private
bool
_isChecked
;
public
bool
IsChecked
{
get
{
return
_isChecked
;
}
set
{
SetProperty
(
ref
_isChecked
,
value
);
}
}
public
string
MemberName
{
get
{
return
MemberSymbol
.
ToDisplayString
(
s_memberDisplayFormat
);
}
}
public
ImageSource
Glyph
{
get
{
return
MemberSymbol
.
GetGlyph
().
GetImageSource
(
_glyphService
);
}
}
public
string
MemberAutomationText
public
MemberSymbolViewModel
(
ISymbol
symbol
,
IGlyphService
glyphService
)
:
base
(
symbol
,
glyphService
)
{
get
{
return
MemberSymbol
.
Kind
+
" "
+
MemberName
;
}
}
}
}
...
...
src/VisualStudio/Core/Def/Implementation/ExtractInterface/VisualStudioExtractInterfaceOptionsService.cs
浏览文件 @
651452ee
...
...
@@ -57,7 +57,7 @@ public VisualStudioExtractInterfaceOptionsService(IGlyphService glyphService, IT
if
(
result
.
HasValue
&&
result
.
Value
)
{
var
includedMembers
=
viewModel
.
MemberContainers
.
Where
(
c
=>
c
.
IsChecked
).
Select
(
c
=>
c
.
Member
Symbol
);
var
includedMembers
=
viewModel
.
MemberContainers
.
Where
(
c
=>
c
.
IsChecked
).
Select
(
c
=>
c
.
Symbol
);
return
new
ExtractInterfaceOptionsResult
(
isCancelled
:
false
,
...
...
src/VisualStudio/Core/Test/ExtractInterface/ExtractInterfaceViewModelTests.vb
浏览文件 @
651452ee
...
...
@@ -394,7 +394,7 @@ class $$MyClass
}
"]]></Text>
Dim viewModel = Await GetViewModelAsync(markup, LanguageNames.CSharp, "
IMyClass
")
Assert.Equal("
Goo
<
T
>
(
T
,
CorrelationManager
,
ref
int
,
[
int
?]
,
[
string
]
,
params
int
[]
)
", viewModel.MemberContainers.Single().
Member
Name)
Assert.Equal("
Goo
<
T
>
(
T
,
CorrelationManager
,
ref
int
,
[
int
?]
,
[
string
]
,
params
int
[]
)
", viewModel.MemberContainers.Single().
Symbol
Name)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.ExtractInterface)>
...
...
@@ -411,7 +411,7 @@ class $$MyClass
}"
]]
></
Text
>
Dim
viewModel
=
Await
GetViewModelAsync
(
markup
,
LanguageNames
.
CSharp
,
"IMyClass"
)
Assert
.
Equal
(
"Goo"
,
viewModel
.
MemberContainers
.
Where
(
Function
(
c
)
c
.
MemberSymbol
.
IsKind
(
SymbolKind
.
Property
)).
Single
().
Member
Name
)
Assert
.
Equal
(
"Goo"
,
viewModel
.
MemberContainers
.
Where
(
Function
(
c
)
c
.
Symbol
.
IsKind
(
SymbolKind
.
Property
)).
Single
().
Symbol
Name
)
End
Function
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
ExtractInterface
)
>
...
...
@@ -424,7 +424,22 @@ class $$MyClass
}
"]]></Text>
Dim viewModel = Await GetViewModelAsync(markup, LanguageNames.CSharp, "
IMyClass
")
Assert.Equal("
this
[
int
?
,
[
string
]]
", viewModel.MemberContainers.Where(Function(c) c.MemberSymbol.IsKind(SymbolKind.Property)).Single().MemberName)
Assert.Equal("
this
[
int
?
,
[
string
]]
", viewModel.MemberContainers.Where(Function(c) c.Symbol.IsKind(SymbolKind.Property)).Single().SymbolName)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.ExtractInterface)>
<WorkItem(37176, "
https
:
//
github
.
com
/
dotnet
/
roslyn
/
issues
/
37176
")>
Public Async Function TestExtractInterface_MemberDisplay_NullableReferenceType() As Task
Dim markup = <Text><![CDATA[
#nullable enable
using System.Collections.Generic;
class $$MyClass
{
public void M(string? s, IEnumerable<string?> e) { }
}"
]]
></
Text
>
Dim
viewModel
=
Await
GetViewModelAsync
(
markup
,
LanguageNames
.
CSharp
,
"IMyClass"
)
Assert
.
Equal
(
"M(string?, IEnumerable<string?>)"
,
viewModel
.
MemberContainers
.
Single
(
Function
(
c
)
c
.
Symbol
.
IsKind
(
SymbolKind
.
Method
)).
SymbolName
)
End
Function
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
ExtractInterface
)
>
...
...
@@ -441,11 +456,11 @@ public class $$MyClass
Dim viewModel = Await GetViewModelAsync(markup, LanguageNames.CSharp, "
IMyClass
")
Assert.Equal(5, viewModel.MemberContainers.Count)
Assert
.
Equal
(
"Goo()"
,
viewModel
.
MemberContainers
.
ElementAt
(
0
).
Member
Name
)
Assert
.
Equal
(
"Goo(int)"
,
viewModel
.
MemberContainers
.
ElementAt
(
1
).
Member
Name
)
Assert
.
Equal
(
"Goo(int, int)"
,
viewModel
.
MemberContainers
.
ElementAt
(
2
).
Member
Name
)
Assert
.
Equal
(
"Goo(int, string)"
,
viewModel
.
MemberContainers
.
ElementAt
(
3
).
Member
Name
)
Assert
.
Equal
(
"Goo(string)"
,
viewModel
.
MemberContainers
.
ElementAt
(
4
).
Member
Name
)
Assert.Equal("
Goo
()
", viewModel.MemberContainers.ElementAt(0).
Symbol
Name)
Assert.Equal("
Goo
(
int
)
", viewModel.MemberContainers.ElementAt(1).
Symbol
Name)
Assert.Equal("
Goo
(
int
,
int
)
", viewModel.MemberContainers.ElementAt(2).
Symbol
Name)
Assert.Equal("
Goo
(
int
,
string
)
", viewModel.MemberContainers.ElementAt(3).
Symbol
Name)
Assert.Equal("
Goo
(
string
)
", viewModel.MemberContainers.ElementAt(4).
Symbol
Name)
End Function
Private Async Function GetViewModelAsync(markup As XElement,
...
...
src/VisualStudio/IntegrationTest/TestUtilities/InProcess/ExtractInterfaceDialog_InProc.cs
浏览文件 @
651452ee
...
...
@@ -124,7 +124,7 @@ public string[] GetSelectedItems()
return
listItems
.
Cast
<
ExtractInterfaceDialogViewModel
.
MemberSymbolViewModel
>()
.
Where
(
viewModel
=>
viewModel
.
IsChecked
)
.
Select
(
viewModel
=>
viewModel
.
Member
Name
)
.
Select
(
viewModel
=>
viewModel
.
Symbol
Name
)
.
ToArray
();
});
}
...
...
@@ -142,7 +142,7 @@ public void ToggleItem(string item)
var
memberSelectionList
=
dialog
.
GetTestAccessor
().
Members
;
var
items
=
memberSelectionList
.
Items
.
Cast
<
ExtractInterfaceDialogViewModel
.
MemberSymbolViewModel
>().
ToArray
();
var
itemViewModel
=
items
.
Single
(
x
=>
x
.
Member
Name
==
item
);
var
itemViewModel
=
items
.
Single
(
x
=>
x
.
Symbol
Name
==
item
);
itemViewModel
.
IsChecked
=
!
itemViewModel
.
IsChecked
;
// Wait for changes to propagate
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录