Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
f09e6d9e
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,发现更多精彩内容 >>
提交
f09e6d9e
编写于
2月 07, 2017
作者:
C
CyrusNajmabadi
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'generateMethodRefReturns2' into generateMethodRefReturns
上级
03fa639f
48f88547
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
61 addition
and
66 deletion
+61
-66
src/EditorFeatures/CSharpTest/Diagnostics/GenerateMethod/GenerateMethodTests.cs
...arpTest/Diagnostics/GenerateMethod/GenerateMethodTests.cs
+1
-0
src/Features/CSharp/Portable/GenerateMember/GenerateParameterizedMember/CSharpGenerateConversionService.cs
...ateParameterizedMember/CSharpGenerateConversionService.cs
+14
-12
src/Features/CSharp/Portable/GenerateMember/GenerateParameterizedMember/CSharpGenerateMethodService.cs
...enerateParameterizedMember/CSharpGenerateMethodService.cs
+6
-16
src/Features/CSharp/Portable/GenerateMember/GenerateParameterizedMember/CSharpGenerateParameterizedMemberService.cs
...terizedMember/CSharpGenerateParameterizedMemberService.cs
+4
-4
src/Features/Core/Portable/GenerateMember/GenerateParameterizedMember/AbstractGenerateMethodService.State.cs
...arameterizedMember/AbstractGenerateMethodService.State.cs
+4
-3
src/Features/Core/Portable/GenerateMember/GenerateParameterizedMember/AbstractGenerateMethodService.cs
...erateParameterizedMember/AbstractGenerateMethodService.cs
+1
-1
src/Features/Core/Portable/GenerateMember/GenerateParameterizedMember/AbstractGenerateParameterizedMemberService.MethodSignatureInfo.cs
...GenerateParameterizedMemberService.MethodSignatureInfo.cs
+1
-1
src/Features/Core/Portable/GenerateMember/GenerateParameterizedMember/AbstractGenerateParameterizedMemberService.SignatureInfo.cs
...stractGenerateParameterizedMemberService.SignatureInfo.cs
+5
-3
src/Features/VisualBasic/Portable/GenerateMember/GenerateParameterizedMember/VisualBasicGenerateConversionService.vb
...rameterizedMember/VisualBasicGenerateConversionService.vb
+14
-18
src/Features/VisualBasic/Portable/GenerateMember/GenerateParameterizedMember/VisualBasicGenerateMethodService.vb
...teParameterizedMember/VisualBasicGenerateMethodService.vb
+1
-1
src/Features/VisualBasic/Portable/GenerateMember/GenerateParameterizedMember/VisualBasicGenerateParameterizedMemberService.vb
...edMember/VisualBasicGenerateParameterizedMemberService.vb
+2
-2
src/Workspaces/CSharp/Portable/LanguageServices/CSharpTypeInferenceService.TypeInferrer.cs
...nguageServices/CSharpTypeInferenceService.TypeInferrer.cs
+6
-4
src/Workspaces/Core/Portable/Shared/Extensions/IMethodSymbolExtensions.cs
...ore/Portable/Shared/Extensions/IMethodSymbolExtensions.cs
+2
-1
未找到文件。
src/EditorFeatures/CSharpTest/Diagnostics/GenerateMethod/GenerateMethodTests.cs
浏览文件 @
f09e6d9e
...
...
@@ -7361,6 +7361,7 @@ private object Issue(int i)
}"
);
}
[
WorkItem
(
16398
,
"https://github.com/dotnet/roslyn/issues/16398"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateMethod
)]
public
async
Task
TestReturnsByRef
()
{
...
...
src/Features/CSharp/Portable/GenerateMember/GenerateParameterizedMember/CSharpGenerateConversionService.cs
浏览文件 @
f09e6d9e
...
...
@@ -38,7 +38,8 @@ protected override bool ContainingTypesOrSelfHasUnsafeKeyword(INamedTypeSymbol c
return
containingType
.
ContainingTypesOrSelfHasUnsafeKeyword
();
}
protected
override
AbstractInvocationInfo
CreateInvocationMethodInfo
(
SemanticDocument
document
,
AbstractGenerateParameterizedMemberService
<
CSharpGenerateConversionService
,
SimpleNameSyntax
,
ExpressionSyntax
,
InvocationExpressionSyntax
>.
State
state
)
protected
override
AbstractInvocationInfo
CreateInvocationMethodInfo
(
SemanticDocument
document
,
AbstractGenerateParameterizedMemberService
<
CSharpGenerateConversionService
,
SimpleNameSyntax
,
ExpressionSyntax
,
InvocationExpressionSyntax
>.
State
state
)
{
return
new
CSharpGenerateParameterizedMemberService
<
CSharpGenerateConversionService
>.
InvocationExpressionInfo
(
document
,
state
);
}
...
...
@@ -196,7 +197,8 @@ protected override bool IsValidSymbol(ISymbol symbol, SemanticModel semanticMode
return
true
;
}
private
static
IMethodSymbol
GenerateMethodSymbol
(
INamedTypeSymbol
typeToGenerateIn
,
INamedTypeSymbol
parameterSymbol
)
private
static
IMethodSymbol
GenerateMethodSymbol
(
INamedTypeSymbol
typeToGenerateIn
,
INamedTypeSymbol
parameterSymbol
)
{
// Remove any generic parameters
if
(
typeToGenerateIn
.
IsGenericType
)
...
...
@@ -205,16 +207,16 @@ private static IMethodSymbol GenerateMethodSymbol(INamedTypeSymbol typeToGenerat
}
return
CodeGenerationSymbolFactory
.
CreateMethodSymbol
(
attributes
:
SpecializedCollections
.
EmptyList
<
AttributeData
>(),
accessibility
:
default
(
Accessibility
),
modifiers
:
default
(
DeclarationModifiers
),
returnType
:
typeToGenerateIn
,
returnsByRef
:
false
,
explicitInterfaceSymbol
:
null
,
name
:
null
,
typeParameters
:
SpecializedCollections
.
EmptyList
<
ITypeParameterSymbol
>(),
parameters
:
new
[]
{
CodeGenerationSymbolFactory
.
CreateParameterSymbol
(
parameterSymbol
,
"v"
)
},
methodKind
:
MethodKind
.
Conversion
);
attributes
:
SpecializedCollections
.
EmptyList
<
AttributeData
>(),
accessibility
:
default
(
Accessibility
),
modifiers
:
default
(
DeclarationModifiers
),
returnType
:
typeToGenerateIn
,
returnsByRef
:
false
,
explicitInterfaceSymbol
:
null
,
name
:
null
,
typeParameters
:
SpecializedCollections
.
EmptyList
<
ITypeParameterSymbol
>(),
parameters
:
new
[]
{
CodeGenerationSymbolFactory
.
CreateParameterSymbol
(
parameterSymbol
,
"v"
)
},
methodKind
:
MethodKind
.
Conversion
);
}
protected
override
string
GetImplicitConversionDisplayText
(
AbstractGenerateParameterizedMemberService
<
CSharpGenerateConversionService
,
SimpleNameSyntax
,
ExpressionSyntax
,
InvocationExpressionSyntax
>.
State
state
)
...
...
src/Features/CSharp/Portable/GenerateMember/GenerateParameterizedMember/CSharpGenerateMethodService.cs
浏览文件 @
f09e6d9e
...
...
@@ -21,19 +21,13 @@ internal partial class CSharpGenerateMethodService :
AbstractGenerateMethodService
<
CSharpGenerateMethodService
,
SimpleNameSyntax
,
ExpressionSyntax
,
InvocationExpressionSyntax
>
{
protected
override
bool
IsExplicitInterfaceGeneration
(
SyntaxNode
node
)
{
return
node
is
MethodDeclarationSyntax
;
}
=>
node
is
MethodDeclarationSyntax
;
protected
override
bool
IsSimpleNameGeneration
(
SyntaxNode
node
)
{
return
node
is
SimpleNameSyntax
;
}
=>
node
is
SimpleNameSyntax
;
protected
override
bool
ContainingTypesOrSelfHasUnsafeKeyword
(
INamedTypeSymbol
containingType
)
{
return
containingType
.
ContainingTypesOrSelfHasUnsafeKeyword
();
}
=>
containingType
.
ContainingTypesOrSelfHasUnsafeKeyword
();
protected
override
AbstractInvocationInfo
CreateInvocationMethodInfo
(
SemanticDocument
document
,
AbstractGenerateParameterizedMemberService
<
CSharpGenerateMethodService
,
SimpleNameSyntax
,
ExpressionSyntax
,
InvocationExpressionSyntax
>.
State
state
)
{
...
...
@@ -41,14 +35,10 @@ protected override AbstractInvocationInfo CreateInvocationMethodInfo(SemanticDoc
}
protected
override
bool
AreSpecialOptionsActive
(
SemanticModel
semanticModel
)
{
return
CSharpCommonGenerationServiceMethods
.
AreSpecialOptionsActive
(
semanticModel
);
}
=>
CSharpCommonGenerationServiceMethods
.
AreSpecialOptionsActive
(
semanticModel
);
protected
override
bool
IsValidSymbol
(
ISymbol
symbol
,
SemanticModel
semanticModel
)
{
return
CSharpCommonGenerationServiceMethods
.
IsValidSymbol
(
symbol
,
semanticModel
);
}
=>
CSharpCommonGenerationServiceMethods
.
IsValidSymbol
(
symbol
,
semanticModel
);
protected
override
bool
TryInitializeExplicitInterfaceState
(
SemanticDocument
document
,
...
...
@@ -154,7 +144,7 @@ protected override bool IsValidSymbol(ISymbol symbol, SemanticModel semanticMode
return
false
;
}
protected
override
ITypeSymbol
CanGenerateMethod
ForSimpleNameOrMemberAccessExpression
(
protected
override
ITypeSymbol
DetermineReturnType
ForSimpleNameOrMemberAccessExpression
(
ITypeInferenceService
typeInferenceService
,
SemanticModel
semanticModel
,
ExpressionSyntax
expression
,
...
...
src/Features/CSharp/Portable/GenerateMember/GenerateParameterizedMember/CSharpGenerateParameterizedMemberService.cs
浏览文件 @
f09e6d9e
...
...
@@ -37,20 +37,20 @@ protected override ImmutableArray<ParameterName> DetermineParameterNames(Cancell
_invocationExpression
.
ArgumentList
);
}
protected
override
bool
DetermineReturnsByRef
(
CancellationToken
cancellationToken
)
=>
_invocationExpression
.
IsParentKind
(
SyntaxKind
.
RefExpression
);
protected
override
ITypeSymbol
DetermineReturnTypeWorker
(
CancellationToken
cancellationToken
)
{
// Defer to the type inferrer to figure out what the return type of this new method
// should be.
var
typeInference
=
this
.
Document
.
Project
.
LanguageServices
.
Get
Service
<
ITypeInferenceService
>();
var
typeInference
=
this
.
Document
.
Document
.
GetLanguage
Service
<
ITypeInferenceService
>();
var
inferredType
=
typeInference
.
InferType
(
this
.
Document
.
SemanticModel
,
_invocationExpression
,
objectAsDefault
:
true
,
nameOpt
:
this
.
State
.
IdentifierToken
.
ValueText
,
cancellationToken
:
cancellationToken
);
return
inferredType
;
}
protected
override
bool
DetermineReturnsByRef
()
=>
_invocationExpression
.
IsParentKind
(
SyntaxKind
.
RefExpression
);
protected
override
ImmutableArray
<
ITypeParameterSymbol
>
GetCapturedTypeParameters
(
CancellationToken
cancellationToken
)
{
var
result
=
new
List
<
ITypeParameterSymbol
>();
...
...
src/Features/Core/Portable/GenerateMember/GenerateParameterizedMember/AbstractGenerateMethodService.State.cs
浏览文件 @
f09e6d9e
...
...
@@ -150,7 +150,7 @@ internal new class State : AbstractGenerateParameterizedMemberService<TService,
}
else
{
var
typeInference
=
document
.
Project
.
LanguageServices
.
Get
Service
<
ITypeInferenceService
>();
var
typeInference
=
document
.
Document
.
GetLanguage
Service
<
ITypeInferenceService
>();
var
delegateType
=
typeInference
.
InferDelegateType
(
semanticModel
,
this
.
SimpleNameOrMemberAccessExpression
,
cancellationToken
);
if
(
delegateType
!=
null
&&
delegateType
.
DelegateInvokeMethod
!=
null
)
{
...
...
@@ -160,7 +160,7 @@ internal new class State : AbstractGenerateParameterizedMemberService<TService,
{
// We don't have and invocation expression or a delegate, but we may have a special expression without parenthesis. Lets see
// if the type inference service can directly infer the type for our expression.
var
expressionType
=
service
.
CanGenerateMethod
ForSimpleNameOrMemberAccessExpression
(
typeInference
,
semanticModel
,
this
.
SimpleNameOrMemberAccessExpression
,
cancellationToken
);
var
expressionType
=
service
.
DetermineReturnType
ForSimpleNameOrMemberAccessExpression
(
typeInference
,
semanticModel
,
this
.
SimpleNameOrMemberAccessExpression
,
cancellationToken
);
if
(
expressionType
==
null
)
{
return
false
;
...
...
@@ -212,7 +212,8 @@ internal new class State : AbstractGenerateParameterizedMemberService<TService,
return
true
;
}
private
static
IMethodSymbol
CreateMethodSymbolWithReturnType
(
ITypeSymbol
expressionType
)
private
static
IMethodSymbol
CreateMethodSymbolWithReturnType
(
ITypeSymbol
expressionType
)
{
return
CodeGenerationSymbolFactory
.
CreateMethodSymbol
(
attributes
:
SpecializedCollections
.
EmptyList
<
AttributeData
>(),
...
...
src/Features/Core/Portable/GenerateMember/GenerateParameterizedMember/AbstractGenerateMethodService.cs
浏览文件 @
f09e6d9e
...
...
@@ -22,7 +22,7 @@ internal abstract partial class AbstractGenerateMethodService<TService, TSimpleN
protected
abstract
bool
IsExplicitInterfaceGeneration
(
SyntaxNode
node
);
protected
abstract
bool
TryInitializeExplicitInterfaceState
(
SemanticDocument
document
,
SyntaxNode
node
,
CancellationToken
cancellationToken
,
out
SyntaxToken
identifierToken
,
out
IMethodSymbol
methodSymbol
,
out
INamedTypeSymbol
typeToGenerateIn
);
protected
abstract
bool
TryInitializeSimpleNameState
(
SemanticDocument
document
,
TSimpleNameSyntax
simpleName
,
CancellationToken
cancellationToken
,
out
SyntaxToken
identifierToken
,
out
TExpressionSyntax
simpleNameOrMemberAccessExpression
,
out
TInvocationExpressionSyntax
invocationExpressionOpt
,
out
bool
isInConditionalExpression
);
protected
abstract
ITypeSymbol
CanGenerateMethod
ForSimpleNameOrMemberAccessExpression
(
ITypeInferenceService
typeInferenceService
,
SemanticModel
semanticModel
,
TExpressionSyntax
expression
,
CancellationToken
cancellationToken
);
protected
abstract
ITypeSymbol
DetermineReturnType
ForSimpleNameOrMemberAccessExpression
(
ITypeInferenceService
typeInferenceService
,
SemanticModel
semanticModel
,
TExpressionSyntax
expression
,
CancellationToken
cancellationToken
);
public
async
Task
<
ImmutableArray
<
CodeAction
>>
GenerateMethodAsync
(
Document
document
,
...
...
src/Features/Core/Portable/GenerateMember/GenerateParameterizedMember/AbstractGenerateParameterizedMemberService.MethodSignatureInfo.cs
浏览文件 @
f09e6d9e
...
...
@@ -26,7 +26,7 @@ protected class MethodSignatureInfo : SignatureInfo
protected
override
ITypeSymbol
DetermineReturnTypeWorker
(
CancellationToken
cancellationToken
)
=>
_methodSymbol
.
ReturnType
;
protected
override
bool
DetermineReturnsByRef
()
protected
override
bool
DetermineReturnsByRef
(
CancellationToken
cancellationToken
)
=>
_methodSymbol
.
ReturnsByRef
;
protected
override
ImmutableArray
<
ITypeParameterSymbol
>
DetermineTypeParametersWorker
(
CancellationToken
cancellationToken
)
...
...
src/Features/Core/Portable/GenerateMember/GenerateParameterizedMember/AbstractGenerateParameterizedMemberService.SignatureInfo.cs
浏览文件 @
f09e6d9e
...
...
@@ -41,7 +41,7 @@ public ImmutableArray<ITypeParameterSymbol> DetermineTypeParameters(Cancellation
}
protected
abstract
ImmutableArray
<
ITypeParameterSymbol
>
DetermineTypeParametersWorker
(
CancellationToken
cancellationToken
);
protected
abstract
bool
DetermineReturnsByRef
();
protected
abstract
bool
DetermineReturnsByRef
(
CancellationToken
cancellationToken
);
public
ITypeSymbol
DetermineReturnType
(
CancellationToken
cancellationToken
)
{
...
...
@@ -79,7 +79,7 @@ public ITypeSymbol DetermineReturnType(CancellationToken cancellationToken)
accessibility
:
accessibility
,
modifiers
:
new
DeclarationModifiers
(
isStatic
:
State
.
IsStatic
,
isAbstract
:
isAbstract
),
type
:
DetermineReturnType
(
cancellationToken
),
returnsByRef
:
DetermineReturnsByRef
(),
returnsByRef
:
DetermineReturnsByRef
(
cancellationToken
),
explicitInterfaceSymbol
:
null
,
name
:
this
.
State
.
IdentifierToken
.
ValueText
,
parameters
:
DetermineParameters
(
cancellationToken
),
...
...
@@ -100,12 +100,14 @@ public ITypeSymbol DetermineReturnType(CancellationToken cancellationToken)
isUnsafe
=
returnType
.
IsUnsafe
()
||
parameters
.
Any
(
p
=>
p
.
Type
.
IsUnsafe
());
}
var
returnsByRef
=
DetermineReturnsByRef
(
cancellationToken
);
var
method
=
CodeGenerationSymbolFactory
.
CreateMethodSymbol
(
attributes
:
null
,
accessibility
:
DetermineAccessibility
(
isAbstract
),
modifiers
:
new
DeclarationModifiers
(
isStatic
:
State
.
IsStatic
,
isAbstract
:
isAbstract
,
isUnsafe
:
isUnsafe
),
returnType
:
returnType
,
returnsByRef
:
DetermineReturnsByRef
()
,
returnsByRef
:
returnsByRef
,
explicitInterfaceSymbol
:
null
,
name
:
this
.
State
.
IdentifierToken
.
ValueText
,
typeParameters
:
DetermineTypeParameters
(
cancellationToken
),
...
...
src/Features/VisualBasic/Portable/GenerateMember/GenerateParameterizedMember/VisualBasicGenerateConversionService.vb
浏览文件 @
f09e6d9e
...
...
@@ -8,7 +8,6 @@ Imports Microsoft.CodeAnalysis.GenerateMember.GenerateParameterizedMember
Imports
Microsoft.CodeAnalysis.Host.Mef
Imports
Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace
Microsoft.CodeAnalysis.VisualBasic.GenerateMember.GenerateMethod
<
ExportLanguageService
(
GetType
(
IGenerateConversionService
),
LanguageNames
.
VisualBasic
),
[
Shared
]
>
Partial
Friend
Class
VisualBasicGenerateConversionService
...
...
@@ -138,19 +137,19 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.GenerateMember.GenerateMethod
typeToGenerateIn
=
typeToGenerateIn
.
ConstructUnboundGenericType
.
ConstructedFrom
End
If
Return
CodeGenerationSymbolFactory
.
CreateMethodSymbol
(
attributes
:
=
SpecializedCollections
.
EmptyList
(
Of
AttributeData
),
accessibility
:
=
Nothing
,
modifiers
:
=
Nothing
,
returnType
:
=
typeToGenerateIn
,
returnsByRef
:
=
False
,
explicitInterfaceSymbol
:
=
Nothing
,
name
:
=
Nothing
,
typeParameters
:
=
SpecializedCollections
.
EmptyList
(
Of
ITypeParameterSymbol
),
parameters
:
=
{
CodeGenerationSymbolFactory
.
CreateParameterSymbol
(
parameterSymbol
,
"v"
)},
statements
:
=
Nothing
,
handlesExpressions
:
=
Nothing
,
returnTypeAttributes
:
=
Nothing
,
methodKind
:
=
MethodKind
.
Conversion
)
attributes
:
=
SpecializedCollections
.
EmptyList
(
Of
AttributeData
),
accessibility
:
=
Nothing
,
modifiers
:
=
Nothing
,
returnType
:
=
typeToGenerateIn
,
returnsByRef
:
=
False
,
explicitInterfaceSymbol
:
=
Nothing
,
name
:
=
Nothing
,
typeParameters
:
=
SpecializedCollections
.
EmptyList
(
Of
ITypeParameterSymbol
),
parameters
:
=
{
CodeGenerationSymbolFactory
.
CreateParameterSymbol
(
parameterSymbol
,
"v"
)},
statements
:
=
Nothing
,
handlesExpressions
:
=
Nothing
,
returnTypeAttributes
:
=
Nothing
,
methodKind
:
=
MethodKind
.
Conversion
)
End
Function
Protected
Overrides
Function
GetExplicitConversionDisplayText
(
state
As
AbstractGenerateParameterizedMemberService
(
Of
VisualBasicGenerateConversionService
,
SimpleNameSyntax
,
ExpressionSyntax
,
InvocationExpressionSyntax
).
State
)
As
String
...
...
@@ -161,7 +160,4 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.GenerateMember.GenerateMethod
Return
String
.
Format
(
VBFeaturesResources
.
Generate_widening_conversion_in_0
,
state
.
TypeToGenerateIn
.
Name
)
End
Function
End
Class
End
Namespace
End
Namespace
\ No newline at end of file
src/Features/VisualBasic/Portable/GenerateMember/GenerateParameterizedMember/VisualBasicGenerateMethodService.vb
浏览文件 @
f09e6d9e
...
...
@@ -152,7 +152,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.GenerateMember.GenerateMethod
Return
New
VisualBasicGenerateParameterizedMemberService
(
Of
VisualBasicGenerateMethodService
).
InvocationExpressionInfo
(
document
,
state
)
End
Function
Protected
Overrides
Function
CanGenerateMethod
ForSimpleNameOrMemberAccessExpression
(
typeInferenceService
As
ITypeInferenceService
,
semanticModel
As
SemanticModel
,
expression
As
ExpressionSyntax
,
cancellationToken
As
CancellationToken
)
As
ITypeSymbol
Protected
Overrides
Function
DetermineReturnType
ForSimpleNameOrMemberAccessExpression
(
typeInferenceService
As
ITypeInferenceService
,
semanticModel
As
SemanticModel
,
expression
As
ExpressionSyntax
,
cancellationToken
As
CancellationToken
)
As
ITypeSymbol
Return
typeInferenceService
.
InferType
(
semanticModel
,
expression
,
True
,
cancellationToken
)
End
Function
End
Class
...
...
src/Features/VisualBasic/Portable/GenerateMember/GenerateParameterizedMember/VisualBasicGenerateParameterizedMemberService.vb
浏览文件 @
f09e6d9e
...
...
@@ -31,12 +31,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.GenerateMember.GenerateMethod
Me
.
InvocationExpression
.
ArgumentList
,
reservedNames
:
=
typeParametersNames
)
End
Function
Protected
Overrides
Function
DetermineReturnsByRef
()
As
Boolean
Protected
Overrides
Function
DetermineReturnsByRef
(
cancellationToken
As
CancellationToken
)
As
Boolean
Return
False
End
Function
Protected
Overrides
Function
DetermineReturnTypeWorker
(
cancellationToken
As
CancellationToken
)
As
ITypeSymbol
Select
Case
CType
(
Me
.
State
.
IdentifierToken
,
SyntaxToken
)
.
GetTypeCharacter
()
Select
Case
Me
.
State
.
IdentifierToken
.
GetTypeCharacter
()
Case
TypeCharacter
.
Integer
Return
Me
.
Document
.
SemanticModel
.
Compilation
.
GetSpecialType
(
SpecialType
.
System_Int32
)
Case
TypeCharacter
.
Long
...
...
src/Workspaces/CSharp/Portable/LanguageServices/CSharpTypeInferenceService.TypeInferrer.cs
浏览文件 @
f09e6d9e
...
...
@@ -87,7 +87,11 @@ private IEnumerable<TypeInferenceInfo> GetTypesComplex(ExpressionSyntax expressi
private
IEnumerable
<
TypeInferenceInfo
>
GetTypesSimple
(
ExpressionSyntax
expression
)
{
if
(
expression
!=
null
)
if
(
expression
is
RefTypeSyntax
refType
)
{
return
GetTypes
(
refType
.
Type
);
}
else
if
(
expression
!=
null
)
{
var
typeInfo
=
SemanticModel
.
GetTypeInfo
(
expression
,
CancellationToken
);
var
symbolInfo
=
SemanticModel
.
GetSymbolInfo
(
expression
,
CancellationToken
);
...
...
@@ -1804,9 +1808,7 @@ private static ITypeSymbol GetMemberType(ISymbol memberSymbol)
}
private
IEnumerable
<
TypeInferenceInfo
>
InferTypeInRefExpression
(
RefExpressionSyntax
refExpression
)
{
return
InferTypes
(
refExpression
);
}
=>
InferTypes
(
refExpression
);
private
IEnumerable
<
TypeInferenceInfo
>
InferTypeForReturnStatement
(
ReturnStatementSyntax
returnStatement
,
SyntaxToken
?
previousToken
=
null
)
{
...
...
src/Workspaces/Core/Portable/Shared/Extensions/IMethodSymbolExtensions.cs
浏览文件 @
f09e6d9e
...
...
@@ -85,7 +85,8 @@ public static IMethodSymbol RenameTypeParameters(this IMethodSymbol method, ILis
p
.
HasExplicitDefaultValue
,
p
.
HasExplicitDefaultValue
?
p
.
ExplicitDefaultValue
:
null
)).
ToList
());
}
public
static
IMethodSymbol
RenameParameters
(
this
IMethodSymbol
method
,
IList
<
string
>
parameterNames
)
public
static
IMethodSymbol
RenameParameters
(
this
IMethodSymbol
method
,
IList
<
string
>
parameterNames
)
{
var
parameterList
=
method
.
Parameters
;
if
(
parameterList
.
Select
(
p
=>
p
.
Name
).
SequenceEqual
(
parameterNames
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录