Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
bf91e3f3
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,发现更多精彩内容 >>
提交
bf91e3f3
编写于
7月 27, 2020
作者:
C
Cyrus Najmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Pass options
上级
9a702ff8
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
37 addition
and
27 deletion
+37
-27
src/VisualStudio/Core/Impl/CodeModel/AbstractCodeModelObject_CodeGen.cs
...io/Core/Impl/CodeModel/AbstractCodeModelObject_CodeGen.cs
+26
-10
src/VisualStudio/Core/Impl/CodeModel/FileCodeModel_CodeGen.cs
...VisualStudio/Core/Impl/CodeModel/FileCodeModel_CodeGen.cs
+9
-5
src/VisualStudio/Core/Test/CodeModel/CSharp/CodeClassTests.vb
...VisualStudio/Core/Test/CodeModel/CSharp/CodeClassTests.vb
+2
-12
未找到文件。
src/VisualStudio/Core/Impl/CodeModel/AbstractCodeModelObject_CodeGen.cs
浏览文件 @
bf91e3f3
...
...
@@ -7,6 +7,7 @@
using
Microsoft.CodeAnalysis
;
using
Microsoft.CodeAnalysis.CodeGeneration
;
using
Microsoft.CodeAnalysis.Editing
;
using
Microsoft.CodeAnalysis.Options
;
namespace
Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel
{
...
...
@@ -17,12 +18,13 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel
public
partial
class
AbstractCodeModelObject
{
private
static
CodeGenerationOptions
GetCodeGenerationOptions
(
EnvDTE
.
vsCMAccess
access
,
ParseOptions
parseOptions
)
EnvDTE
.
vsCMAccess
access
,
ParseOptions
parseOptions
,
OptionSet
options
)
{
var
generateDefaultAccessibility
=
(
access
&
EnvDTE
.
vsCMAccess
.
vsCMAccessDefault
)
==
0
;
return
new
CodeGenerationOptions
(
generateDefaultAccessibility
:
generateDefaultAccessibility
,
parseOptions
:
parseOptions
);
parseOptions
:
parseOptions
,
options
:
options
);
}
protected
SyntaxNode
CreateConstructorDeclaration
(
SyntaxNode
containerNode
,
string
typeName
,
EnvDTE
.
vsCMAccess
access
)
...
...
@@ -38,7 +40,8 @@ protected SyntaxNode CreateConstructorDeclaration(SyntaxNode containerNode, stri
return
CodeGenerationService
.
CreateMethodDeclaration
(
newMethodSymbol
,
destination
,
options
:
GetCodeGenerationOptions
(
access
,
containerNode
.
SyntaxTree
.
Options
));
options
:
GetCodeGenerationOptions
(
access
,
containerNode
.
SyntaxTree
.
Options
,
options
:
null
));
}
protected
SyntaxNode
CreateDestructorDeclaration
(
SyntaxNode
containerNode
,
string
typeName
)
...
...
@@ -67,7 +70,8 @@ protected SyntaxNode CreateDelegateTypeDeclaration(SyntaxNode containerNode, str
return
CodeGenerationService
.
CreateNamedTypeDeclaration
(
newTypeSymbol
,
destination
,
options
:
GetCodeGenerationOptions
(
access
,
containerNode
.
SyntaxTree
.
Options
));
options
:
GetCodeGenerationOptions
(
access
,
containerNode
.
SyntaxTree
.
Options
,
options
:
null
));
}
protected
SyntaxNode
CreateEventDeclaration
(
SyntaxNode
containerNode
,
string
name
,
EnvDTE
.
vsCMAccess
access
,
ITypeSymbol
type
,
bool
createPropertyStyleEvent
)
...
...
@@ -114,7 +118,8 @@ protected SyntaxNode CreateEventDeclaration(SyntaxNode containerNode, string nam
return
CodeGenerationService
.
CreateEventDeclaration
(
newEventSymbol
,
destination
,
options
:
GetCodeGenerationOptions
(
access
,
containerNode
.
SyntaxTree
.
Options
));
options
:
GetCodeGenerationOptions
(
access
,
containerNode
.
SyntaxTree
.
Options
,
options
:
null
));
}
protected
SyntaxNode
CreateFieldDeclaration
(
SyntaxNode
containerNode
,
string
name
,
EnvDTE
.
vsCMAccess
access
,
ITypeSymbol
type
)
...
...
@@ -130,7 +135,8 @@ protected SyntaxNode CreateFieldDeclaration(SyntaxNode containerNode, string nam
return
CodeGenerationService
.
CreateFieldDeclaration
(
newFieldSymbol
,
destination
,
options
:
GetCodeGenerationOptions
(
access
,
containerNode
.
SyntaxTree
.
Options
));
options
:
GetCodeGenerationOptions
(
access
,
containerNode
.
SyntaxTree
.
Options
,
options
:
null
));
}
protected
SyntaxNode
CreateMethodDeclaration
(
SyntaxNode
containerNode
,
string
name
,
EnvDTE
.
vsCMAccess
access
,
ITypeSymbol
returnType
)
...
...
@@ -148,7 +154,8 @@ protected SyntaxNode CreateMethodDeclaration(SyntaxNode containerNode, string na
typeParameters
:
default
,
parameters
:
default
);
var
codeGenerationOptions
=
GetCodeGenerationOptions
(
access
,
containerNode
.
SyntaxTree
.
Options
);
var
codeGenerationOptions
=
GetCodeGenerationOptions
(
access
,
containerNode
.
SyntaxTree
.
Options
,
options
:
null
);
if
(
destination
==
CodeGenerationDestination
.
InterfaceType
)
{
// Generating method with body is allowed when targeting an interface,
...
...
@@ -161,7 +168,14 @@ protected SyntaxNode CreateMethodDeclaration(SyntaxNode containerNode, string na
options
:
codeGenerationOptions
);
}
protected
SyntaxNode
CreatePropertyDeclaration
(
SyntaxNode
containerNode
,
string
name
,
bool
generateGetter
,
bool
generateSetter
,
EnvDTE
.
vsCMAccess
access
,
ITypeSymbol
type
)
protected
SyntaxNode
CreatePropertyDeclaration
(
SyntaxNode
containerNode
,
string
name
,
bool
generateGetter
,
bool
generateSetter
,
EnvDTE
.
vsCMAccess
access
,
ITypeSymbol
type
,
OptionSet
options
)
{
var
destination
=
CodeModelService
.
GetDestination
(
containerNode
);
...
...
@@ -210,7 +224,8 @@ protected SyntaxNode CreatePropertyDeclaration(SyntaxNode containerNode, string
return
CodeGenerationService
.
CreatePropertyDeclaration
(
newPropertySymbol
,
destination
,
options
:
GetCodeGenerationOptions
(
access
,
containerNode
.
SyntaxTree
.
Options
));
options
:
GetCodeGenerationOptions
(
access
,
containerNode
.
SyntaxTree
.
Options
,
options
));
}
protected
SyntaxNode
CreateNamespaceDeclaration
(
SyntaxNode
containerNode
,
string
name
)
...
...
@@ -249,7 +264,8 @@ protected SyntaxNode CreateNamespaceDeclaration(SyntaxNode containerNode, string
return
CodeGenerationService
.
CreateNamedTypeDeclaration
(
newTypeSymbol
,
destination
,
options
:
GetCodeGenerationOptions
(
access
,
containerNode
.
SyntaxTree
.
Options
));
options
:
GetCodeGenerationOptions
(
access
,
containerNode
.
SyntaxTree
.
Options
,
options
:
null
));
}
}
}
src/VisualStudio/Core/Impl/CodeModel/FileCodeModel_CodeGen.cs
浏览文件 @
bf91e3f3
...
...
@@ -375,12 +375,16 @@ internal EnvDTE.CodeProperty AddProperty(SyntaxNode containerNode, string getter
var
containerNodePosition
=
containerNode
.
SpanStart
;
var
semanticModel
=
GetSemanticModel
();
var
options
=
GetDocument
().
GetOptionsAsync
(
CancellationToken
.
None
).
WaitAndGetResult_CodeModel
(
CancellationToken
.
None
);
var
propertyType
=
CodeModelService
.
GetTypeSymbol
(
type
,
semanticModel
,
containerNodePosition
);
var
newProperty
=
CreatePropertyDeclaration
(
containerNode
,
CodeModelService
.
GetUnescapedName
(
isGetterPresent
?
getterName
:
putterName
),
isGetterPresent
,
isPutterPresent
,
access
,
propertyType
);
var
newProperty
=
CreatePropertyDeclaration
(
containerNode
,
CodeModelService
.
GetUnescapedName
(
isGetterPresent
?
getterName
:
putterName
),
isGetterPresent
,
isPutterPresent
,
access
,
propertyType
,
options
);
var
insertionIndex
=
CodeModelService
.
PositionVariantToMemberInsertionIndex
(
position
,
containerNode
,
fileCodeModel
:
this
);
newProperty
=
InsertMember
(
containerNode
,
newProperty
,
insertionIndex
);
...
...
src/VisualStudio/Core/Test/CodeModel/CSharp/CodeClassTests.vb
浏览文件 @
bf91e3f3
...
...
@@ -2187,11 +2187,7 @@ class C
{
string
Name
{
get
{
return
default
;
}
get
=&
gt
;
default
;
set
{
}
...
...
@@ -2241,13 +2237,7 @@ class C$$
<
Code
>
class
C
{
string
Name
{
get
{
return
default
;
}
}
string
Name
=&
gt
;
default
;
}
</
Code
>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录