Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
7a10daaa
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,发现更多精彩内容 >>
提交
7a10daaa
编写于
9月 15, 2015
作者:
C
Cyrus Najmabadi
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' into spellChecking
上级
848290b4
ba822199
变更
20
隐藏空白更改
内联
并排
Showing
20 changed file
with
352 addition
and
29 deletion
+352
-29
src/Compilers/CSharp/Portable/CodeGen/Optimizer.cs
src/Compilers/CSharp/Portable/CodeGen/Optimizer.cs
+5
-0
src/Compilers/CSharp/Portable/Lowering/AsyncRewriter/AwaitExpressionSpiller.cs
...Portable/Lowering/AsyncRewriter/AwaitExpressionSpiller.cs
+2
-5
src/Compilers/CSharp/Portable/Symbols/LocalSymbol.cs
src/Compilers/CSharp/Portable/Symbols/LocalSymbol.cs
+2
-0
src/Compilers/CSharp/Portable/Symbols/Source/SourceLocalSymbol.cs
...ilers/CSharp/Portable/Symbols/Source/SourceLocalSymbol.cs
+5
-0
src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedLocal.cs
...s/CSharp/Portable/Symbols/Synthesized/SynthesizedLocal.cs
+1
-1
src/Compilers/CSharp/Portable/Symbols/Synthesized/TypeSubstitutedLocalSymbol.cs
...ortable/Symbols/Synthesized/TypeSubstitutedLocalSymbol.cs
+10
-0
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncTests.cs
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncTests.cs
+42
-0
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenMscorlib.cs
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenMscorlib.cs
+80
-0
src/Compilers/VisualBasic/Portable/Binding/Binder_Initializers.vb
...ilers/VisualBasic/Portable/Binding/Binder_Initializers.vb
+11
-11
src/Compilers/VisualBasic/Portable/Binding/InitializerSemanticModel.vb
.../VisualBasic/Portable/Binding/InitializerSemanticModel.vb
+1
-1
src/Compilers/VisualBasic/Portable/Compilation/MethodCompiler.vb
...pilers/VisualBasic/Portable/Compilation/MethodCompiler.vb
+1
-1
src/Compilers/VisualBasic/Portable/Lowering/LocalRewriter/LocalRewriter_FieldOrPropertyInitializer.vb
...LocalRewriter/LocalRewriter_FieldOrPropertyInitializer.vb
+15
-3
src/Compilers/VisualBasic/Portable/Symbols/FieldOrPropertyInitializer.vb
...isualBasic/Portable/Symbols/FieldOrPropertyInitializer.vb
+6
-5
src/Compilers/VisualBasic/Portable/Symbols/Source/SourceMemberContainerTypeSymbol.vb
...ortable/Symbols/Source/SourceMemberContainerTypeSymbol.vb
+1
-1
src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenWithEvents.vb
...pilers/VisualBasic/Test/Emit/CodeGen/CodeGenWithEvents.vb
+121
-0
src/EditorFeatures/CSharp/SignatureHelp/ElementAccessExpressionSignatureHelpProvider.cs
...atureHelp/ElementAccessExpressionSignatureHelpProvider.cs
+4
-1
src/EditorFeatures/CSharpTest/SignatureHelp/ElementAccessExpressionSignatureHelpProviderTests.cs
...Help/ElementAccessExpressionSignatureHelpProviderTests.cs
+24
-0
src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/EELocalSymbolBase.cs
...rp/Source/ExpressionCompiler/Symbols/EELocalSymbolBase.cs
+5
-0
src/InteractiveWindow/Editor/InteractiveWindow.UIThreadOnly.cs
...nteractiveWindow/Editor/InteractiveWindow.UIThreadOnly.cs
+2
-0
src/InteractiveWindow/EditorTest/InteractiveWindowTests.cs
src/InteractiveWindow/EditorTest/InteractiveWindowTests.cs
+14
-0
未找到文件。
src/Compilers/CSharp/Portable/CodeGen/Optimizer.cs
浏览文件 @
7a10daaa
...
...
@@ -1756,6 +1756,11 @@ internal override SynthesizedLocalKind SynthesizedKind
get
{
return
SynthesizedLocalKind
.
OptimizerTemp
;
}
}
internal
override
LocalSymbol
WithSynthesizedLocalKindAndSyntax
(
SynthesizedLocalKind
kind
,
SyntaxNode
syntax
)
{
throw
new
NotImplementedException
();
}
internal
override
SyntaxToken
IdentifierToken
{
get
{
return
default
(
SyntaxToken
);
}
...
...
src/Compilers/CSharp/Portable/Lowering/AsyncRewriter/AwaitExpressionSpiller.cs
浏览文件 @
7a10daaa
...
...
@@ -1107,11 +1107,8 @@ private void PromoteAndAddLocals(BoundSpillSequenceBuilder builder, ImmutableArr
else
{
Debug
.
Assert
(
_F
.
Syntax
.
IsKind
(
SyntaxKind
.
AwaitExpression
));
SynthesizedLocal
shortLived
=
(
SynthesizedLocal
)
local
;
SynthesizedLocal
longLived
=
shortLived
.
WithSynthesizedLocalKindAndSyntax
(
SynthesizedLocalKind
.
AwaitSpill
,
_F
.
Syntax
);
_tempSubstitution
.
Add
(
shortLived
,
longLived
);
LocalSymbol
longLived
=
local
.
WithSynthesizedLocalKindAndSyntax
(
SynthesizedLocalKind
.
AwaitSpill
,
_F
.
Syntax
);
_tempSubstitution
.
Add
(
local
,
longLived
);
builder
.
AddLocal
(
longLived
,
_F
.
Diagnostics
);
}
}
...
...
src/Compilers/CSharp/Portable/Symbols/LocalSymbol.cs
浏览文件 @
7a10daaa
...
...
@@ -25,6 +25,8 @@ protected LocalSymbol()
get
;
}
internal
abstract
LocalSymbol
WithSynthesizedLocalKindAndSyntax
(
SynthesizedLocalKind
kind
,
SyntaxNode
syntax
);
internal
abstract
bool
IsImportedFromMetadata
{
get
;
...
...
src/Compilers/CSharp/Portable/Symbols/Source/SourceLocalSymbol.cs
浏览文件 @
7a10daaa
...
...
@@ -103,6 +103,11 @@ internal override SynthesizedLocalKind SynthesizedKind
get
{
return
SynthesizedLocalKind
.
UserDefined
;
}
}
internal
override
LocalSymbol
WithSynthesizedLocalKindAndSyntax
(
SynthesizedLocalKind
kind
,
SyntaxNode
syntax
)
{
throw
ExceptionUtilities
.
Unreachable
;
}
internal
override
bool
IsPinned
{
get
...
...
src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedLocal.cs
浏览文件 @
7a10daaa
...
...
@@ -70,7 +70,7 @@ public SyntaxNode SyntaxOpt
get
{
return
_syntaxOpt
;
}
}
internal
SynthesizedLoca
l
WithSynthesizedLocalKindAndSyntax
(
SynthesizedLocalKind
kind
,
SyntaxNode
syntax
)
internal
override
LocalSymbo
l
WithSynthesizedLocalKindAndSyntax
(
SynthesizedLocalKind
kind
,
SyntaxNode
syntax
)
{
return
new
SynthesizedLocal
(
_containingMethodOpt
,
...
...
src/Compilers/CSharp/Portable/Symbols/Synthesized/TypeSubstitutedLocalSymbol.cs
浏览文件 @
7a10daaa
...
...
@@ -97,5 +97,15 @@ internal override ImmutableArray<Diagnostic> GetConstantValueDiagnostics(BoundEx
{
return
_originalVariable
.
GetConstantValueDiagnostics
(
boundInitValue
);
}
internal
override
LocalSymbol
WithSynthesizedLocalKindAndSyntax
(
SynthesizedLocalKind
kind
,
SyntaxNode
syntax
)
{
var
origSynthesized
=
(
SynthesizedLocal
)
_originalVariable
;
return
new
TypeSubstitutedLocalSymbol
(
origSynthesized
.
WithSynthesizedLocalKindAndSyntax
(
kind
,
syntax
),
_type
,
_containingSymbol
);
}
}
}
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncTests.cs
浏览文件 @
7a10daaa
...
...
@@ -3400,6 +3400,48 @@ async Task<int> Test(IDisposable id, Task<int> task)
CompileAndVerify
(
comp
.
WithOptions
(
TestOptions
.
ReleaseExe
));
}
[
Fact
,
WorkItem
(
4697
,
"https://github.com/dotnet/roslyn/issues/4697"
)]
public
void
AwaitInObjInitializer
()
{
var
source
=
@"
using System;
using System.Threading.Tasks;
namespace CompilerCrashRepro2
{
public class Item<T>
{
public T Value { get; set; }
}
public class Crasher
{
public static void Main()
{
var r = Build<int>()().Result.Value;
System.Console.WriteLine(r);
}
public static Func<Task<Item<T>>> Build<T>()
{
return async () => new Item<T>()
{
Value = await GetValue<T>()
};
}
public static Task<T> GetValue<T>()
{
return Task.FromResult(default(T));
}
}
}"
;
var
comp
=
CreateCompilation
(
source
,
options
:
TestOptions
.
DebugExe
);
CompileAndVerify
(
comp
,
expectedOutput
:
"0"
);
CompileAndVerify
(
comp
.
WithOptions
(
TestOptions
.
ReleaseExe
),
expectedOutput
:
"0"
);
}
[
Fact
]
public
void
AwaitInScriptExpression
()
{
...
...
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenMscorlib.cs
浏览文件 @
7a10daaa
...
...
@@ -252,6 +252,7 @@ static int M(decimal d)
var
verifier
=
CompileAndVerify
(
compilation2
);
}
[
Fact
,
WorkItem
(
3593
,
"https://github.com/dotnet/roslyn/issues/3593"
)]
public
void
NoTypedRef
()
{
var
source1
=
...
...
@@ -288,6 +289,85 @@ public static T Read<T>()
);
}
[
Fact
,
WorkItem
(
3746
,
"https://github.com/dotnet/roslyn/issues/3746"
)]
public
void
NoTypedRefBox
()
{
var
source1
=
@"namespace System
{
public class Object { }
public struct Void { }
public class ValueType { }
public struct Int32 { }
public struct Decimal { }
}"
;
var
compilation1
=
CreateCompilation
(
source1
,
assemblyName
:
GetUniqueName
());
var
reference1
=
MetadataReference
.
CreateFromStream
(
compilation1
.
EmitToStream
());
var
source2
=
@"
public class C1
{
public static object rrr;
public static T Read<T>() where T : new()
{
T result = new T();
var refresult = __makeref(result);
rrr = refresult;
return result;
}
}
"
;
var
compilation2
=
CreateCompilation
(
source2
,
new
[]
{
reference1
});
compilation2
.
VerifyDiagnostics
(
// (9,25): error CS0518: Predefined type 'System.TypedReference' is not defined or imported
// var refresult = __makeref(result);
Diagnostic
(
ErrorCode
.
ERR_PredefinedTypeNotFound
,
"__makeref(result)"
).
WithArguments
(
"System.TypedReference"
).
WithLocation
(
9
,
25
)
);
}
[
Fact
,
WorkItem
(
3746
,
"https://github.com/dotnet/roslyn/issues/3746"
)]
public
void
NoTypedRefBox1
()
{
var
source1
=
@"namespace System
{
public class Object { }
public struct Void { }
public class ValueType { }
public struct Int32 { }
public struct Decimal { }
public struct TypedReference { }
}"
;
var
compilation1
=
CreateCompilation
(
source1
,
assemblyName
:
GetUniqueName
());
var
reference1
=
MetadataReference
.
CreateFromStream
(
compilation1
.
EmitToStream
());
var
source2
=
@"
public class C1
{
public static object rrr;
public static T Read<T>() where T : new()
{
T result = new T();
var refresult = __makeref(result);
rrr = refresult;
rrr = (object)__makeref(result);
return result;
}
}
"
;
var
compilation2
=
CreateCompilation
(
source2
,
new
[]
{
reference1
});
compilation2
.
VerifyDiagnostics
(
// (10,15): error CS0029: Cannot implicitly convert type 'System.TypedReference' to 'object'
// rrr = refresult;
Diagnostic
(
ErrorCode
.
ERR_NoImplicitConv
,
"refresult"
).
WithArguments
(
"System.TypedReference"
,
"object"
).
WithLocation
(
10
,
15
),
// (11,15): error CS0030: Cannot convert type 'System.TypedReference' to 'object'
// rrr = (object)__makeref(result);
Diagnostic
(
ErrorCode
.
ERR_NoExplicitConv
,
"(object)__makeref(result)"
).
WithArguments
(
"System.TypedReference"
,
"object"
).
WithLocation
(
11
,
15
)
);
}
[
WorkItem
(
530861
,
"DevDiv"
)]
[
Fact
]
public
void
MissingStringLengthForEach
()
...
...
src/Compilers/VisualBasic/Portable/Binding/Binder_Initializers.vb
浏览文件 @
7a10daaa
...
...
@@ -104,7 +104,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
For
j
=
0
To
siblingInitializers
.
Length
-
1
Dim
initializer
=
siblingInitializers
(
j
)
If
Not
initializer
.
FieldsOrPropert
y
.
IsDefault
AndAlso
initializer
.
FieldsOrProperty
.
First
.
ContainingType
.
IsEnumType
Then
If
Not
initializer
.
FieldsOrPropert
ies
.
IsDefault
AndAlso
initializer
.
FieldsOrProperties
.
First
.
ContainingType
.
IsEnumType
Then
Continue
For
End
If
...
...
@@ -123,18 +123,18 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Debug
.
Assert
(
parentBinder
.
SyntaxTree
Is
syntaxTree
,
"sibling initializer array contains initializers from two different syntax trees."
)
End
If
If
initializer
.
FieldsOrPropert
y
.
IsDefault
Then
If
initializer
.
FieldsOrPropert
ies
.
IsDefault
Then
' use the binder of the Script class for global statements
Dim
isLast
=
(
i
=
initializers
.
Length
-
1
AndAlso
j
=
siblingInitializers
.
Length
-
1
)
boundInitializers
.
Add
(
parentBinder
.
BindGlobalStatement
(
scriptInitializerOpt
,
DirectCast
(
initializerNode
,
StatementSyntax
),
diagnostics
,
isLast
))
Continue
For
End
If
Dim
firstFieldOrProperty
=
initializer
.
FieldsOrPropert
y
.
First
Dim
firstFieldOrProperty
=
initializer
.
FieldsOrPropert
ies
.
First
Dim
initializerBinder
=
BinderBuilder
.
CreateBinderForInitializer
(
parentBinder
,
firstFieldOrProperty
)
If
initializerNode
.
Kind
=
SyntaxKind
.
ModifiedIdentifier
Then
' Array field with no explicit initializer.
Debug
.
Assert
(
initializer
.
FieldsOrPropert
y
.
Length
=
1
)
Debug
.
Assert
(
initializer
.
FieldsOrPropert
ies
.
Length
=
1
)
Debug
.
Assert
(
firstFieldOrProperty
.
Kind
=
SymbolKind
.
Field
)
Dim
fieldSymbol
=
DirectCast
(
firstFieldOrProperty
,
SourceFieldSymbol
)
...
...
@@ -178,15 +178,13 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End
If
End
If
initializerBinder
.
BindFieldInitializer
(
initializer
.
FieldsOrPropert
y
,
initializerBinder
.
BindFieldInitializer
(
initializer
.
FieldsOrPropert
ies
,
initializerNode
,
boundInitializers
,
diagnostics
)
End
If
Else
Dim
propertySymbol
=
DirectCast
(
firstFieldOrProperty
,
PropertySymbol
)
initializerBinder
.
BindPropertyInitializer
(
propertySymbol
,
initializerBinder
.
BindPropertyInitializer
(
initializer
.
FieldsOrProperties
,
initializerNode
,
boundInitializers
,
diagnostics
)
...
...
@@ -324,11 +322,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End
Sub
Friend
Sub
BindPropertyInitializer
(
propertySymbol
As
PropertySymbol
,
propertySymbol
s
As
ImmutableArray
(
Of
Symbol
)
,
initValueOrAsNewNode
As
VisualBasicSyntaxNode
,
boundInitializers
As
ArrayBuilder
(
Of
BoundInitializer
),
diagnostics
As
DiagnosticBag
)
Dim
propertySymbol
=
DirectCast
(
propertySymbols
.
First
,
PropertySymbol
)
Dim
syntaxNode
As
VisualBasicSyntaxNode
=
initValueOrAsNewNode
Dim
boundReceiver
=
If
(
propertySymbol
.
IsShared
,
Nothing
,
CreateMeReference
(
syntaxNode
,
isSynthetic
:
=
True
))
...
...
@@ -341,6 +340,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
If
propertySymbol
.
IsReadOnly
AndAlso
propertySymbol
.
AssociatedField
IsNot
Nothing
Then
' For ReadOnly auto-implemented properties we have to write directly to the backing field.
Debug
.
Assert
(
propertySymbol
.
Type
=
propertySymbol
.
AssociatedField
.
Type
)
Debug
.
Assert
(
propertySymbols
.
Length
=
1
)
boundPropertyOrFieldAccess
=
New
BoundFieldAccess
(
syntaxNode
,
boundReceiver
,
propertySymbol
.
AssociatedField
,
...
...
@@ -370,8 +370,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
diagnostics
)
boundInitializers
.
Add
(
New
BoundFieldOrPropertyInitializer
(
initValueOrAsNewNode
,
ImmutableArray
.
Create
(
Of
Symbol
)(
propertySymbol
)
,
boundPropertyOrFieldAccess
,
propertySymbols
,
If
(
propertySymbols
.
Length
=
1
,
boundPropertyOrFieldAccess
,
Nothing
)
,
boundInitExpression
))
End
Sub
...
...
src/Compilers/VisualBasic/Portable/Binding/InitializerSemanticModel.vb
浏览文件 @
7a10daaa
...
...
@@ -118,7 +118,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
' get property symbol
Dim
propertySymbol
=
DirectCast
(
Me
.
MemberSymbol
,
SourcePropertySymbol
)
Dim
boundInitializers
=
ArrayBuilder
(
Of
boundInitializer
).
GetInstance
binder
.
BindPropertyInitializer
(
propertySymbol
,
initializer
,
boundInitializers
,
diagnostics
)
binder
.
BindPropertyInitializer
(
ImmutableArray
.
Create
(
Of
Symbol
)(
propertySymbol
)
,
initializer
,
boundInitializers
,
diagnostics
)
boundInitializer
=
boundInitializers
.
First
boundInitializers
.
Free
()
...
...
src/Compilers/VisualBasic/Portable/Compilation/MethodCompiler.vb
浏览文件 @
7a10daaa
...
...
@@ -425,7 +425,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
For
Each
initializerGroup
In
initializers
If
Not
initializerGroup
.
IsEmpty
Then
For
Each
initializer
In
initializerGroup
For
Each
fieldOrProperty
In
initializer
.
FieldsOrPropert
y
For
Each
fieldOrProperty
In
initializer
.
FieldsOrPropert
ies
Debug
.
Assert
(
fieldOrProperty
.
Kind
=
SymbolKind
.
Field
)
Debug
.
Assert
(
DirectCast
(
fieldOrProperty
,
FieldSymbol
).
IsConst
)
Next
...
...
src/Compilers/VisualBasic/Portable/Lowering/LocalRewriter/LocalRewriter_FieldOrPropertyInitializer.vb
浏览文件 @
7a10daaa
...
...
@@ -59,10 +59,22 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Dim
symbol
=
node
.
InitializedSymbols
(
symbolIndex
)
Dim
accessExpression
As
BoundExpression
' if there are more than one symbol we need to create a field access for each of them
' if there are more than one symbol we need to create a field
or property
access for each of them
If
initializedSymbols
.
Length
>
1
Then
Dim
fieldSymbol
=
DirectCast
(
symbol
,
FieldSymbol
)
accessExpression
=
New
BoundFieldAccess
(
syntax
,
meReferenceOpt
,
fieldSymbol
,
True
,
fieldSymbol
.
Type
)
If
symbol
.
Kind
=
SymbolKind
.
Field
Then
Dim
fieldSymbol
=
DirectCast
(
symbol
,
FieldSymbol
)
accessExpression
=
New
BoundFieldAccess
(
syntax
,
meReferenceOpt
,
fieldSymbol
,
True
,
fieldSymbol
.
Type
)
Else
' We can get here when multiple WithEvents fields are initialized with As New ...
Dim
propertySymbol
=
DirectCast
(
symbol
,
PropertySymbol
)
accessExpression
=
New
BoundPropertyAccess
(
syntax
,
propertySymbol
,
propertyGroupOpt
:
=
Nothing
,
accessKind
:
=
PropertyAccessKind
.
Set
,
isWriteable
:
=
propertySymbol
.
HasSet
,
receiverOpt
:
=
meReferenceOpt
,
arguments
:
=
ImmutableArray
(
Of
BoundExpression
).
Empty
)
End
If
Else
Debug
.
Assert
(
node
.
MemberAccessExpressionOpt
IsNot
Nothing
)
...
...
src/Compilers/VisualBasic/Portable/Symbols/FieldOrPropertyInitializer.vb
浏览文件 @
7a10daaa
...
...
@@ -10,9 +10,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
''' </summary>
Friend
Structure
FieldOrPropertyInitializer
''' <summary>
''' The fields or a property being initialized, or Nothing if this represents an executable statement in script code.
''' The fields or properties being initialized, or Nothing if this represents an executable statement in script code.
''' We can get into a multiple properties case when multiple WithEvents fields are initialized with As New ...
''' </summary>
Public
ReadOnly
FieldsOrPropert
y
As
ImmutableArray
(
Of
Symbol
)
Public
ReadOnly
FieldsOrPropert
ies
As
ImmutableArray
(
Of
Symbol
)
''' <summary>
''' A reference to
...
...
@@ -53,7 +54,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
syntax
.
GetSyntax
().
IsKind
(
SyntaxKind
.
EqualsValue
)
OrElse
syntax
.
GetSyntax
().
IsKind
(
SyntaxKind
.
ModifiedIdentifier
))
Me
.
FieldsOrPropert
y
=
ImmutableArray
.
Create
(
Of
Symbol
)(
field
)
Me
.
FieldsOrPropert
ies
=
ImmutableArray
.
Create
(
Of
Symbol
)(
field
)
Me
.
Syntax
=
syntax
Me
.
IsMetadataConstant
=
field
.
IsMetadataConstant
Me
.
PrecedingInitializersLength
=
precedingInitializersLength
...
...
@@ -65,7 +66,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Public
Sub
New
(
fieldsOrProperties
As
ImmutableArray
(
Of
Symbol
),
syntax
As
SyntaxReference
,
precedingInitializersLength
As
Integer
)
Debug
.
Assert
(
Not
fieldsOrProperties
.
IsEmpty
)
Debug
.
Assert
(
syntax
.
GetSyntax
().
IsKind
(
SyntaxKind
.
AsNewClause
)
OrElse
syntax
.
GetSyntax
().
IsKind
(
SyntaxKind
.
EqualsValue
))
Me
.
FieldsOrPropert
y
=
fieldsOrProperties
Me
.
FieldsOrPropert
ies
=
fieldsOrProperties
Me
.
Syntax
=
syntax
Me
.
IsMetadataConstant
=
False
Me
.
PrecedingInitializersLength
=
precedingInitializersLength
...
...
@@ -81,7 +82,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Debug
.
Assert
(
syntax
IsNot
Nothing
)
Debug
.
Assert
(
syntax
.
GetSyntax
().
IsKind
(
SyntaxKind
.
AsNewClause
)
OrElse
syntax
.
GetSyntax
().
IsKind
(
SyntaxKind
.
EqualsValue
))
Me
.
FieldsOrPropert
y
=
ImmutableArray
.
Create
(
Of
Symbol
)(
[
property
]
)
Me
.
FieldsOrPropert
ies
=
ImmutableArray
.
Create
(
Of
Symbol
)(
[
property
]
)
Me
.
Syntax
=
syntax
Me
.
IsMetadataConstant
=
False
Me
.
PrecedingInitializersLength
=
precedingInitializersLength
...
...
src/Compilers/VisualBasic/Portable/Symbols/Source/SourceMemberContainerTypeSymbol.vb
浏览文件 @
7a10daaa
...
...
@@ -2356,7 +2356,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
If
initializerSet
IsNot
Nothing
Then
For
Each
initializers
In
initializerSet
For
Each
initializer
In
initializers
Dim
fieldOrPropertyArray
As
ImmutableArray
(
Of
Symbol
)
=
initializer
.
FieldsOrPropert
y
Dim
fieldOrPropertyArray
As
ImmutableArray
(
Of
Symbol
)
=
initializer
.
FieldsOrPropert
ies
If
Not
fieldOrPropertyArray
.
IsDefault
Then
Debug
.
Assert
(
fieldOrPropertyArray
.
Length
>
0
)
...
...
src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenWithEvents.vb
浏览文件 @
7a10daaa
...
...
@@ -1998,5 +1998,126 @@ End Class
CompileAndVerify
(
source
)
End
Sub
<
Fact
,
WorkItem
(
4544
,
"https://github.com/dotnet/roslyn/issues/4544"
)
>
Public
Sub
MultipleInitializationsWithAsNew_01
()
Dim
source
=
<
compilation
>
<
file
name
=
"a.vb"
>
Class
C1
Shared
WithEvents
a1
,
b1
,
c1
As
New
C2
()
WithEvents
a2
,
b2
,
c2
As
New
C2
()
Shared
a3
,
b3
,
c3
As
New
C2
()
Dim
a4
,
b4
,
c4
As
New
C2
()
Shared
Sub
Main
()
Check
(
a1
,
b1
,
c1
)
Check
(
a3
,
b3
,
c3
)
Dim
c
as
New
C1
()
Check
(
c
.
a2
,
c
.
b2
,
c
.
c2
)
Check
(
c
.
a4
,
c
.
b4
,
c
.
c4
)
End
Sub
Private
Shared
Sub
Check
(
a
As
Object
,
b
As
Object
,
c
As
Object
)
System
.
Console
.
WriteLine
(
a
Is
Nothing
)
System
.
Console
.
WriteLine
(
b
Is
Nothing
)
System
.
Console
.
WriteLine
(
c
Is
Nothing
)
System
.
Console
.
WriteLine
(
a
Is
b
)
System
.
Console
.
WriteLine
(
a
Is
c
)
System
.
Console
.
WriteLine
(
b
Is
c
)
End
Sub
End
Class
Class
C2
End
Class
</
file
>
</
compilation
>
CompileAndVerify
(
source
,
expectedOutput
:
=
<
!
[
CDATA
[
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False
]]
>
)
End
Sub
<
Fact
,
WorkItem
(
4544
,
"https://github.com/dotnet/roslyn/issues/4544"
)
>
Public
Sub
MultipleInitializationsWithAsNew_02
()
Dim
source
=
<
compilation
>
<
file
name
=
"a.vb"
>
Class
C1
Shared
WithEvents
a
,
b
,
c
As
New
C1
()
With
{.
P1
=
2
}
Shared
Sub
Main
()
System
.
Console
.
WriteLine
(
a
.
P1
)
System
.
Console
.
WriteLine
(
b
.
P1
)
System
.
Console
.
WriteLine
(
c
.
P1
)
System
.
Console
.
WriteLine
(
a
Is
b
)
System
.
Console
.
WriteLine
(
a
Is
c
)
System
.
Console
.
WriteLine
(
b
Is
c
)
End
Sub
Public
P1
As
Integer
End
Class
</
file
>
</
compilation
>
CompileAndVerify
(
source
,
expectedOutput
:
=
<
!
[
CDATA
[
2
2
2
False
False
False
]]
>
).
VerifyIL
(
"C1..cctor"
,
<
!
[
CDATA
[
{
//
Code
size
52
(
0
x34
)
.
maxstack
3
IL_0000
:
newobj
"Sub C1..ctor()"
IL_0005
:
dup
IL_0006
:
ldc
.
i4
.
2
IL_0007
:
stfld
"C1.P1 As Integer"
IL_000c
:
call
"Sub C1.set_a(C1)"
IL_0011
:
newobj
"Sub C1..ctor()"
IL_0016
:
dup
IL_0017
:
ldc
.
i4
.
2
IL_0018
:
stfld
"C1.P1 As Integer"
IL_001d
:
call
"Sub C1.set_b(C1)"
IL_0022
:
newobj
"Sub C1..ctor()"
IL_0027
:
dup
IL_0028
:
ldc
.
i4
.
2
IL_0029
:
stfld
"C1.P1 As Integer"
IL_002e
:
call
"Sub C1.set_c(C1)"
IL_0033
:
ret
}
]]
>
)
End
Sub
End
Class
End
Namespace
src/EditorFeatures/CSharp/SignatureHelp/ElementAccessExpressionSignatureHelpProvider.cs
浏览文件 @
7a10daaa
...
...
@@ -208,7 +208,10 @@ private bool TryGetIndexers(int position, SemanticModel semanticModel, Expressio
if
(
expressionType
is
IErrorTypeSymbol
)
{
expressionType
=
(
expressionType
as
IErrorTypeSymbol
).
CandidateSymbols
.
FirstOrDefault
().
GetSymbolType
();
// If `expression` is a QualifiedNameSyntax then GetTypeInfo().Type won't have any CandidateSymbols, so
// we should then fall back to getting the actual symbol for the expression.
expressionType
=
(
expressionType
as
IErrorTypeSymbol
).
CandidateSymbols
.
FirstOrDefault
().
GetSymbolType
()
??
semanticModel
.
GetSymbolInfo
(
expression
).
GetAnySymbol
().
GetSymbolType
();
}
indexers
=
semanticModel
.
LookupSymbols
(
position
,
expressionType
,
WellKnownMemberNames
.
Indexer
).
OfType
<
IPropertySymbol
>();
...
...
src/EditorFeatures/CSharpTest/SignatureHelp/ElementAccessExpressionSignatureHelpProviderTests.cs
浏览文件 @
7a10daaa
...
...
@@ -833,6 +833,30 @@ public void InvokedWithNoToken()
Test
(
markup
);
}
[
WorkItem
(
2482
,
"https://github.com/dotnet/roslyn/issues/2482"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
SignatureHelp
)]
public
void
WhereExpressionLooksLikeArrayTypeSyntaxOfQualifiedName
()
{
var
markup
=
@"
class WithIndexer
{
public int this[int index] { get { return 0; } }
}
class TestClass
{
public WithIndexer Item { get; set; }
public void Method(TestClass tc)
{
// `tc.Item[]` parses as ArrayTypeSyntax with an ElementType of QualifiedNameSyntax
tc.Item[$$]
}
}
"
;
Test
(
markup
,
new
[]
{
new
SignatureHelpTestItem
(
"int WithIndexer[int index]"
)
},
usePreviousCharAsTrigger
:
true
);
}
}
}
}
src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/EELocalSymbolBase.cs
浏览文件 @
7a10daaa
...
...
@@ -43,6 +43,11 @@ internal sealed override SynthesizedLocalKind SynthesizedKind
get
{
return
SynthesizedLocalKind
.
UserDefined
;
}
}
internal
sealed
override
LocalSymbol
WithSynthesizedLocalKindAndSyntax
(
SynthesizedLocalKind
kind
,
SyntaxNode
syntax
)
{
throw
ExceptionUtilities
.
Unreachable
;
}
internal
sealed
override
bool
IsImportedFromMetadata
{
get
{
return
true
;
}
...
...
src/InteractiveWindow/Editor/InteractiveWindow.UIThreadOnly.cs
浏览文件 @
7a10daaa
...
...
@@ -1956,6 +1956,7 @@ public void Home(bool extendSelection)
TextView
.
Selection
.
Clear
();
caret
.
MoveTo
(
moveTo
);
}
caret
.
EnsureVisible
();
}
/// <summary>
...
...
@@ -1992,6 +1993,7 @@ public void End(bool extendSelection)
TextView
.
Selection
.
Clear
();
caret
.
MoveTo
(
moveTo
);
}
caret
.
EnsureVisible
();
}
/// <summary>Implements <see cref="IInteractiveWindowOperations.SelectAll"/>.</summary>
...
...
src/InteractiveWindow/EditorTest/InteractiveWindowTests.cs
浏览文件 @
7a10daaa
...
...
@@ -349,6 +349,20 @@ public void CallEndOnNonUIThread()
Task
.
Run
(()
=>
Window
.
Operations
.
End
(
true
)).
PumpingWait
();
}
public
void
ScrollToCursorOnHomeAndEndOnNonUIThread
()
{
Window
.
InsertCode
(
new
string
(
'1'
,
512
));
// a long input string
var
textView
=
Window
.
TextView
;
Window
.
Operations
.
Home
(
false
);
Assert
.
True
(
textView
.
TextViewModel
.
IsPointInVisualBuffer
(
textView
.
Caret
.
Position
.
BufferPosition
,
textView
.
Caret
.
Position
.
Affinity
));
Window
.
Operations
.
End
(
false
);
Assert
.
True
(
textView
.
TextViewModel
.
IsPointInVisualBuffer
(
textView
.
Caret
.
Position
.
BufferPosition
,
textView
.
Caret
.
Position
.
Affinity
));
}
[
Fact
]
public
void
CallSelectAllOnNonUIThread
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录