Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
51a1864f
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,发现更多精彩内容 >>
未验证
提交
51a1864f
编写于
11月 16, 2017
作者:
S
Shyam N
提交者:
GitHub
11月 16, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #23213 from dotnet/merges/master-to-post-dev15.5-contrib-20171116-080023
Merge master to post-dev15.5-contrib
上级
4bd448ac
160c4098
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
483 addition
and
12 deletion
+483
-12
src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs
...lers/CSharp/Portable/Operations/CSharpOperationFactory.cs
+17
-5
src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IObjectCreationExpression.cs
...c/IOperation/IOperationTests_IObjectCreationExpression.cs
+178
-0
src/VisualStudio/CSharp/Impl/CodeModel/CSharpCodeModelService.cs
...ualStudio/CSharp/Impl/CodeModel/CSharpCodeModelService.cs
+11
-2
src/VisualStudio/Core/Test/CodeModel/AbstractCodeNamespaceTests.vb
...lStudio/Core/Test/CodeModel/AbstractCodeNamespaceTests.vb
+1
-1
src/VisualStudio/Core/Test/CodeModel/CSharp/CodeAttributeTests.vb
...alStudio/Core/Test/CodeModel/CSharp/CodeAttributeTests.vb
+35
-1
src/VisualStudio/Core/Test/CodeModel/CSharp/CodeNamespaceTests.vb
...alStudio/Core/Test/CodeModel/CSharp/CodeNamespaceTests.vb
+103
-0
src/VisualStudio/Core/Test/CodeModel/VisualBasic/CodeAttributeTests.vb
...dio/Core/Test/CodeModel/VisualBasic/CodeAttributeTests.vb
+39
-1
src/VisualStudio/Core/Test/CodeModel/VisualBasic/CodeNamespaceTests.vb
...dio/Core/Test/CodeModel/VisualBasic/CodeNamespaceTests.vb
+88
-0
src/VisualStudio/VisualBasic/Impl/CodeModel/VisualBasicCodeModelService.vb
...VisualBasic/Impl/CodeModel/VisualBasicCodeModelService.vb
+11
-2
未找到文件。
src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs
浏览文件 @
51a1864f
...
...
@@ -594,7 +594,9 @@ private IObjectOrCollectionInitializerOperation CreateBoundCollectionInitializer
private
IOperation
CreateBoundObjectInitializerMemberOperation
(
BoundObjectInitializerMember
boundObjectInitializerMember
)
{
Lazy
<
IOperation
>
instance
=
boundObjectInitializerMember
.
MemberSymbol
.
IsStatic
?
Symbol
memberSymbol
=
boundObjectInitializerMember
.
MemberSymbol
;
Lazy
<
IOperation
>
instance
=
memberSymbol
?.
IsStatic
==
true
?
OperationFactory
.
NullOperation
:
new
Lazy
<
IOperation
>(()
=>
new
InstanceReferenceExpression
(
...
...
@@ -609,17 +611,27 @@ private IOperation CreateBoundObjectInitializerMemberOperation(BoundObjectInitia
Optional
<
object
>
constantValue
=
ConvertToOptional
(
boundObjectInitializerMember
.
ConstantValue
);
bool
isImplicit
=
boundObjectInitializerMember
.
WasCompilerGenerated
;
switch
(
boundObjectInitializerMember
.
MemberSymbol
.
Kind
)
if
((
object
)
memberSymbol
==
null
)
{
Debug
.
Assert
(
boundObjectInitializerMember
.
Type
.
IsDynamic
());
Lazy
<
ImmutableArray
<
IOperation
>>
arguments
=
new
Lazy
<
ImmutableArray
<
IOperation
>>(()
=>
boundObjectInitializerMember
.
Arguments
.
SelectAsArray
(
n
=>
Create
(
n
)));
ImmutableArray
<
string
>
argumentNames
=
boundObjectInitializerMember
.
ArgumentNamesOpt
.
NullToEmpty
();
ImmutableArray
<
RefKind
>
argumentRefKinds
=
boundObjectInitializerMember
.
ArgumentRefKindsOpt
.
NullToEmpty
();
return
new
LazyDynamicIndexerAccessExpression
(
instance
,
arguments
,
argumentNames
,
argumentRefKinds
,
_semanticModel
,
syntax
,
type
,
constantValue
,
isImplicit
);
}
switch
(
memberSymbol
.
Kind
)
{
case
SymbolKind
.
Field
:
var
field
=
(
FieldSymbol
)
boundObjectInitializerMember
.
M
emberSymbol
;
var
field
=
(
FieldSymbol
)
m
emberSymbol
;
bool
isDeclaration
=
false
;
return
new
LazyFieldReferenceExpression
(
field
,
isDeclaration
,
instance
,
_semanticModel
,
syntax
,
type
,
constantValue
,
isImplicit
);
case
SymbolKind
.
Event
:
var
eventSymbol
=
(
EventSymbol
)
boundObjectInitializerMember
.
M
emberSymbol
;
var
eventSymbol
=
(
EventSymbol
)
m
emberSymbol
;
return
new
LazyEventReferenceExpression
(
eventSymbol
,
instance
,
_semanticModel
,
syntax
,
type
,
constantValue
,
isImplicit
);
case
SymbolKind
.
Property
:
var
property
=
(
PropertySymbol
)
boundObjectInitializerMember
.
M
emberSymbol
;
var
property
=
(
PropertySymbol
)
m
emberSymbol
;
Lazy
<
ImmutableArray
<
IArgumentOperation
>>
arguments
;
if
(!
boundObjectInitializerMember
.
Arguments
.
Any
())
{
...
...
src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IObjectCreationExpression.cs
浏览文件 @
51a1864f
...
...
@@ -604,5 +604,183 @@ public void M1()
VerifyOperationTreeAndDiagnosticsForTest
<
ObjectCreationExpressionSyntax
>(
source
,
expectedOperationTree
,
expectedDiagnostics
);
}
[
CompilerTrait
(
CompilerFeature
.
IOperation
)]
[
Fact
]
[
WorkItem
(
23154
,
"https://github.com/dotnet/roslyn/issues/23154"
)]
public
void
ObjectCreationWithDynamicMemberInitializer_01
()
{
string
source
=
@"
#pragma warning disable 0169
class A
{
dynamic this[int x, int y]
{
get
{
return new A();
}
}
dynamic this[string x, string y]
{
get
{
throw null;
}
}
int X, Y, Z;
static void Main()
{
dynamic x = 1;
new A {/*<bind>*/[y: x, x: x] = { X = 1, Y = 1, Z = 1 }/*</bind>*/ };
}
}
"
;
string
expectedOperationTree
=
@"
IMemberInitializerOperation (OperationKind.MemberInitializer, Type: dynamic) (Syntax: '[y: x, x: x ... 1, Z = 1 }')
InitializedMember:
IDynamicIndexerAccessOperation (OperationKind.DynamicIndexerAccess, Type: dynamic) (Syntax: '[y: x, x: x]')
Expression:
IInstanceReferenceOperation (OperationKind.InstanceReference, Type: A, IsImplicit) (Syntax: '[y: x, x: x]')
Arguments(2):
ILocalReferenceOperation: x (OperationKind.LocalReference, Type: dynamic) (Syntax: 'x')
ILocalReferenceOperation: x (OperationKind.LocalReference, Type: dynamic) (Syntax: 'x')
ArgumentNames(2):
""y""
""x""
ArgumentRefKinds(0)
Initializer:
IObjectOrCollectionInitializerOperation (OperationKind.ObjectOrCollectionInitializer, Type: dynamic) (Syntax: '{ X = 1, Y = 1, Z = 1 }')
Initializers(3):
ISimpleAssignmentOperation (OperationKind.SimpleAssignment, Type: dynamic) (Syntax: 'X = 1')
Left:
IOperation: (OperationKind.None, Type: null) (Syntax: 'X')
Right:
ILiteralOperation (OperationKind.Literal, Type: System.Int32, Constant: 1) (Syntax: '1')
ISimpleAssignmentOperation (OperationKind.SimpleAssignment, Type: dynamic) (Syntax: 'Y = 1')
Left:
IOperation: (OperationKind.None, Type: null) (Syntax: 'Y')
Right:
ILiteralOperation (OperationKind.Literal, Type: System.Int32, Constant: 1) (Syntax: '1')
ISimpleAssignmentOperation (OperationKind.SimpleAssignment, Type: dynamic) (Syntax: 'Z = 1')
Left:
IOperation: (OperationKind.None, Type: null) (Syntax: 'Z')
Right:
ILiteralOperation (OperationKind.Literal, Type: System.Int32, Constant: 1) (Syntax: '1')
"
;
var
expectedDiagnostics
=
DiagnosticDescription
.
None
;
VerifyOperationTreeAndDiagnosticsForTest
<
AssignmentExpressionSyntax
>(
source
,
expectedOperationTree
,
expectedDiagnostics
);
}
[
CompilerTrait
(
CompilerFeature
.
IOperation
)]
[
Fact
]
[
WorkItem
(
23154
,
"https://github.com/dotnet/roslyn/issues/23154"
)]
public
void
ObjectCreationWithDynamicMemberInitializer_02
()
{
string
source
=
@"
#pragma warning disable 0169
class A
{
dynamic this[int x, int y]
{
get
{
return new A();
}
}
dynamic this[string x, string y]
{
get
{
throw null;
}
}
int X, Y, Z;
static void Main()
{
dynamic x = 1;
new A {/*<bind>*/[y: x, x: x] = { }/*</bind>*/ };
}
}
"
;
string
expectedOperationTree
=
@"
IMemberInitializerOperation (OperationKind.MemberInitializer, Type: dynamic) (Syntax: '[y: x, x: x] = { }')
InitializedMember:
IDynamicIndexerAccessOperation (OperationKind.DynamicIndexerAccess, Type: dynamic) (Syntax: '[y: x, x: x]')
Expression:
IInstanceReferenceOperation (OperationKind.InstanceReference, Type: A, IsImplicit) (Syntax: '[y: x, x: x]')
Arguments(2):
ILocalReferenceOperation: x (OperationKind.LocalReference, Type: dynamic) (Syntax: 'x')
ILocalReferenceOperation: x (OperationKind.LocalReference, Type: dynamic) (Syntax: 'x')
ArgumentNames(2):
""y""
""x""
ArgumentRefKinds(0)
Initializer:
IObjectOrCollectionInitializerOperation (OperationKind.ObjectOrCollectionInitializer, Type: dynamic) (Syntax: '{ }')
Initializers(0)
"
;
var
expectedDiagnostics
=
DiagnosticDescription
.
None
;
VerifyOperationTreeAndDiagnosticsForTest
<
AssignmentExpressionSyntax
>(
source
,
expectedOperationTree
,
expectedDiagnostics
);
}
[
CompilerTrait
(
CompilerFeature
.
IOperation
)]
[
Fact
]
[
WorkItem
(
23154
,
"https://github.com/dotnet/roslyn/issues/23154"
)]
public
void
ObjectCreationWithDynamicMemberInitializer_03
()
{
string
source
=
@"
#pragma warning disable 0169
class A
{
dynamic this[int x, int y]
{
get
{
return new A();
}
}
dynamic this[string x, string y]
{
get
{
throw null;
}
}
int X, Y, Z;
static void Main()
{
dynamic x = 1;
new A {/*<bind>*/[y: x, x: x]/*</bind>*/ = { } };
}
}
"
;
string
expectedOperationTree
=
@"
IDynamicIndexerAccessOperation (OperationKind.DynamicIndexerAccess, Type: dynamic) (Syntax: '[y: x, x: x]')
Expression:
IInstanceReferenceOperation (OperationKind.InstanceReference, Type: A, IsImplicit) (Syntax: '[y: x, x: x]')
Arguments(2):
ILocalReferenceOperation: x (OperationKind.LocalReference, Type: dynamic) (Syntax: 'x')
ILocalReferenceOperation: x (OperationKind.LocalReference, Type: dynamic) (Syntax: 'x')
ArgumentNames(2):
""y""
""x""
ArgumentRefKinds(0)
"
;
var
expectedDiagnostics
=
DiagnosticDescription
.
None
;
VerifyOperationTreeAndDiagnosticsForTest
<
ExpressionSyntax
>(
source
,
expectedOperationTree
,
expectedDiagnostics
);
}
}
}
src/VisualStudio/CSharp/Impl/CodeModel/CSharpCodeModelService.cs
浏览文件 @
51a1864f
...
...
@@ -879,6 +879,9 @@ public override SyntaxNode SetName(SyntaxNode node, string name)
throw
new
ArgumentNullException
(
nameof
(
node
));
}
// In all cases, the resulting syntax for the new name has elastic trivia attached,
// whether via this call to SyntaxFactory.Identifier or via explicitly added elastic
// markers.
SyntaxToken
newIdentifier
=
SyntaxFactory
.
Identifier
(
name
);
switch
(
node
.
Kind
())
{
...
...
@@ -904,13 +907,19 @@ public override SyntaxNode SetName(SyntaxNode node, string name)
case
SyntaxKind
.
Parameter
:
return
((
ParameterSyntax
)
node
).
WithIdentifier
(
newIdentifier
);
case
SyntaxKind
.
NamespaceDeclaration
:
return
((
NamespaceDeclarationSyntax
)
node
).
WithName
(
SyntaxFactory
.
IdentifierName
(
name
));
return
((
NamespaceDeclarationSyntax
)
node
).
WithName
(
SyntaxFactory
.
ParseName
(
name
)
.
WithLeadingTrivia
(
SyntaxFactory
.
TriviaList
(
SyntaxFactory
.
ElasticMarker
))
.
WithTrailingTrivia
(
SyntaxFactory
.
TriviaList
(
SyntaxFactory
.
ElasticMarker
)));
case
SyntaxKind
.
EnumMemberDeclaration
:
return
((
EnumMemberDeclarationSyntax
)
node
).
WithIdentifier
(
newIdentifier
);
case
SyntaxKind
.
VariableDeclarator
:
return
((
VariableDeclaratorSyntax
)
node
).
WithIdentifier
(
newIdentifier
);
case
SyntaxKind
.
Attribute
:
return
((
AttributeSyntax
)
node
).
WithName
(
SyntaxFactory
.
IdentifierName
(
name
));
return
((
AttributeSyntax
)
node
).
WithName
(
SyntaxFactory
.
ParseName
(
name
)
.
WithLeadingTrivia
(
SyntaxFactory
.
TriviaList
(
SyntaxFactory
.
ElasticMarker
))
.
WithTrailingTrivia
(
SyntaxFactory
.
TriviaList
(
SyntaxFactory
.
ElasticMarker
)));
case
SyntaxKind
.
AttributeArgument
:
return
((
AttributeArgumentSyntax
)
node
).
WithNameEquals
(
SyntaxFactory
.
NameEquals
(
SyntaxFactory
.
IdentifierName
(
name
)));
default
:
...
...
src/VisualStudio/Core/Test/CodeModel/AbstractCodeNamespaceTests.vb
浏览文件 @
51a1864f
...
...
@@ -41,7 +41,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.CodeModel
End
Function
Protected
Overrides
Function
GetNameSetter
(
codeElement
As
EnvDTE
.
CodeNamespace
)
As
Action
(
Of
String
)
Throw
New
NotImplementedException
()
Return
Sub
(
name
)
codeElement
.
Name
=
name
End
Function
Protected
Overrides
Function
GetParent
(
codeElement
As
EnvDTE
.
CodeNamespace
)
As
Object
...
...
src/VisualStudio/Core/Test/CodeModel/CSharp/CodeAttributeTests.vb
浏览文件 @
51a1864f
...
...
@@ -861,7 +861,7 @@ class CAttribute : Attribute { }
#Region "Set Name tests"
<
ConditionalWpfFact
(
GetType
(
x86
)),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeModel
)
>
Public
Async
Function
TestSetName
1
()
As
Task
Public
Async
Function
TestSetName
_NewName
()
As
Task
Dim
code
=
<
Code
>
[$$
Goo
]
...
...
@@ -876,6 +876,40 @@ class C { }
Await
TestSetName
(
code
,
expected
,
"Bar"
,
NoThrow
(
Of
String
)())
End
Function
<
ConditionalWpfFact
(
GetType
(
x86
)),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeModel
)
>
Public
Async
Function
TestSetName_SimpleNameToDottedName
()
As
Task
Dim
code
=
<
Code
>
[$$
Goo
]
class
C
{
}
</
Code
>
Dim
expected
=
<
Code
>
[
Bar
.
Baz
]
class
C
{
}
</
Code
>
Await
TestSetName
(
code
,
expected
,
"Bar.Baz"
,
NoThrow
(
Of
String
)())
End
Function
<
ConditionalWpfFact
(
GetType
(
x86
)),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeModel
)
>
Public
Async
Function
TestSetName_DottedNameToSimpleName
()
As
Task
Dim
code
=
<
Code
>
[$$
Goo
.
Bar
]
class
C
{
}
</
Code
>
Dim
expected
=
<
Code
>
[
Baz
]
class
C
{
}
</
Code
>
Await
TestSetName
(
code
,
expected
,
"Baz"
,
NoThrow
(
Of
String
)())
End
Function
#End Region
#Region "Set Target tests"
...
...
src/VisualStudio/Core/Test/CodeModel/CSharp/CodeNamespaceTests.vb
浏览文件 @
51a1864f
...
...
@@ -389,6 +389,109 @@ namespace N1
#End Region
#Region "Set Name tests"
<
ConditionalWpfFact
(
GetType
(
x86
)),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeModel
)
>
Public
Async
Function
TestSetName_SameName
()
As
Task
Dim
code
=
<
Code
><
!
[
CDATA
[
namespace
N
$$
{
class
C
{
}
}
]]
></
Code
>
Dim
expected
=
<
Code
><
!
[
CDATA
[
namespace
N
{
class
C
{
}
}
]]
></
Code
>
Await
TestSetName
(
code
,
expected
,
"N"
,
NoThrow
(
Of
String
)())
End
Function
<
ConditionalWpfFact
(
GetType
(
x86
)),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeModel
)
>
Public
Async
Function
TestSetName_NewName
()
As
Task
Dim
code
=
<
Code
><
!
[
CDATA
[
namespace
N
$$
{
class
C
{
}
}
]]
></
Code
>
Dim
expected
=
<
Code
><
!
[
CDATA
[
namespace
N2
{
class
C
{
}
}
]]
></
Code
>
Await
TestSetName
(
code
,
expected
,
"N2"
,
NoThrow
(
Of
String
)())
End
Function
<
ConditionalWpfFact
(
GetType
(
x86
)),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeModel
)
>
Public
Async
Function
TestSetName_SimpleNameToDottedName
()
As
Task
Dim
code
=
<
Code
><
!
[
CDATA
[
namespace
N1
$$
{
class
C
{
}
}
]]
></
Code
>
Dim
expected
=
<
Code
><
!
[
CDATA
[
namespace
N2
.
N3
{
class
C
{
}
}
]]
></
Code
>
Await
TestSetName
(
code
,
expected
,
"N2.N3"
,
NoThrow
(
Of
String
)())
End
Function
<
ConditionalWpfFact
(
GetType
(
x86
)),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeModel
)
>
Public
Async
Function
TestSetName_DottedNameToSimpleName
()
As
Task
Dim
code
=
<
Code
><
!
[
CDATA
[
namespace
N1
.
N2
$$
{
class
C
{
}
}
]]
></
Code
>
Dim
expected
=
<
Code
><
!
[
CDATA
[
namespace
N3
.
N4
{
class
C
{
}
}
]]
></
Code
>
Await
TestSetName
(
code
,
expected
,
"N3.N4"
,
NoThrow
(
Of
String
)())
End
Function
#End Region
#Region "Remove tests"
<
ConditionalWpfFact
(
GetType
(
x86
)),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeModel
)
>
...
...
src/VisualStudio/Core/Test/CodeModel/VisualBasic/CodeAttributeTests.vb
浏览文件 @
51a1864f
...
...
@@ -1065,7 +1065,7 @@ End Class
#Region "Set Name tests"
<
ConditionalWpfFact
(
GetType
(
x86
)),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeModel
)
>
Public
Async
Function
TestSetName
1
()
As
Task
Public
Async
Function
TestSetName
_NewName
()
As
Task
Dim
code
=
<
Code
><
!
[
CDATA
[
<
$$
Goo
()
>
...
...
@@ -1082,6 +1082,44 @@ End Class
Await
TestSetName
(
code
,
expected
,
"Bar"
,
NoThrow
(
Of
String
)())
End
Function
<
ConditionalWpfFact
(
GetType
(
x86
)),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeModel
)
>
Public
Async
Function
TestSetName_SimpleNameToDottedName
()
As
Task
Dim
code
=
<
Code
><
!
[
CDATA
[
<
$$
Goo
()
>
Class
C
End
Class
]]
></
Code
>
Dim
expected
=
<
Code
><
!
[
CDATA
[
<
Bar
.
Baz
()
>
Class
C
End
Class
]]
></
Code
>
Await
TestSetName
(
code
,
expected
,
"Bar.Baz"
,
NoThrow
(
Of
String
)())
End
Function
<
ConditionalWpfFact
(
GetType
(
x86
)),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeModel
)
>
Public
Async
Function
TestSetName_DottedNameToSimpleName
()
As
Task
Dim
code
=
<
Code
><
!
[
CDATA
[
<
$$
Goo
()
>
Class
C
End
Class
]]
></
Code
>
Dim
expected
=
<
Code
><
!
[
CDATA
[
<
Bar
.
Baz
()
>
Class
C
End
Class
]]
></
Code
>
Await
TestSetName
(
code
,
expected
,
"Bar.Baz"
,
NoThrow
(
Of
String
)())
End
Function
#End Region
#Region "Set Target tests"
...
...
src/VisualStudio/Core/Test/CodeModel/VisualBasic/CodeNamespaceTests.vb
浏览文件 @
51a1864f
...
...
@@ -821,6 +821,94 @@ End Namespace
#End Region
#Region "Set Name tests"
<
ConditionalWpfFact
(
GetType
(
x86
)),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeModel
)
>
Public
Async
Function
TestSetName_SameName
()
As
Task
Dim
code
=
<
Code
>
Namespace
N
$$
Class
C
End
Class
End
Namespace
</
Code
>
Dim
expected
=
<
Code
>
Namespace
N
Class
C
End
Class
End
Namespace
</
Code
>
Await
TestSetName
(
code
,
expected
,
"N"
,
NoThrow
(
Of
String
)())
End
Function
<
ConditionalWpfFact
(
GetType
(
x86
)),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeModel
)
>
Public
Async
Function
TestSetName_NewName
()
As
Task
Dim
code
=
<
Code
>
Namespace
N
$$
Class
C
End
Class
End
Namespace
</
Code
>
Dim
expected
=
<
Code
>
Namespace
N2
Class
C
End
Class
End
Namespace
</
Code
>
Await
TestSetName
(
code
,
expected
,
"N2"
,
NoThrow
(
Of
String
)())
End
Function
<
ConditionalWpfFact
(
GetType
(
x86
)),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeModel
)
>
Public
Async
Function
TestSetName_SimpleNameToDottedName
()
As
Task
Dim
code
=
<
Code
>
Namespace
N1
$$
Class
C
End
Class
End
Namespace
</
Code
>
Dim
expected
=
<
Code
>
Namespace
N2.N3
Class
C
End
Class
End
Namespace
</
Code
>
Await
TestSetName
(
code
,
expected
,
"N2.N3"
,
NoThrow
(
Of
String
)())
End
Function
<
ConditionalWpfFact
(
GetType
(
x86
)),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeModel
)
>
Public
Async
Function
TestSetName_DottedNameToDottedName
()
As
Task
Dim
code
=
<
Code
>
Namespace
N1.N2
$$
Class
C
End
Class
End
Namespace
</
Code
>
Dim
expected
=
<
Code
>
Namespace
N3.N4
Class
C
End
Class
End
Namespace
</
Code
>
Await
TestSetName
(
code
,
expected
,
"N3.N4"
,
NoThrow
(
Of
String
)())
End
Function
#End Region
#Region "Remove tests"
<
ConditionalWpfFact
(
GetType
(
x86
)),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeModel
)
>
...
...
src/VisualStudio/VisualBasic/Impl/CodeModel/VisualBasicCodeModelService.vb
浏览文件 @
51a1864f
...
...
@@ -941,11 +941,17 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.CodeModel
Throw
New
ArgumentNullException
(
NameOf
(
node
))
End
If
' In all cases, the resulting syntax for the new name has elastic trivia attached,
' whether via this call to SyntaxFactory.Identifier or via explicitly added elastic
' markers.
Dim
identifier
As
SyntaxToken
=
SyntaxFactory
.
Identifier
(
name
)
Select
Case
node
.
Kind
Case
SyntaxKind
.
Attribute
Return
DirectCast
(
node
,
AttributeSyntax
).
WithName
(
SyntaxFactory
.
ParseTypeName
(
name
))
Return
DirectCast
(
node
,
AttributeSyntax
).
WithName
(
SyntaxFactory
.
ParseTypeName
(
name
)
_
.
WithLeadingTrivia
(
SyntaxFactory
.
TriviaList
(
SyntaxFactory
.
ElasticMarker
))
_
.
WithTrailingTrivia
(
SyntaxFactory
.
TriviaList
(
SyntaxFactory
.
ElasticMarker
)))
Case
SyntaxKind
.
ClassStatement
Return
DirectCast
(
node
,
ClassStatementSyntax
).
WithIdentifier
(
identifier
)
Case
SyntaxKind
.
InterfaceStatement
...
...
@@ -960,7 +966,10 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.CodeModel
SyntaxKind
.
DelegateSubStatement
Return
DirectCast
(
node
,
DelegateStatementSyntax
).
WithIdentifier
(
identifier
)
Case
SyntaxKind
.
NamespaceStatement
Return
DirectCast
(
node
,
NamespaceStatementSyntax
).
WithName
(
SyntaxFactory
.
ParseName
(
name
))
Return
DirectCast
(
node
,
NamespaceStatementSyntax
).
WithName
(
SyntaxFactory
.
ParseName
(
name
)
_
.
WithLeadingTrivia
(
SyntaxFactory
.
TriviaList
(
SyntaxFactory
.
ElasticMarker
))
_
.
WithTrailingTrivia
(
SyntaxFactory
.
TriviaList
(
SyntaxFactory
.
ElasticMarker
)))
Case
SyntaxKind
.
SubStatement
,
SyntaxKind
.
FunctionStatement
,
SyntaxKind
.
SubNewStatement
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录