Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
cdb3a9c7
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,发现更多精彩内容 >>
提交
cdb3a9c7
编写于
2月 22, 2017
作者:
O
Omar Tawfik
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reverse readonly ref to ref readonly in declarations
上级
b007ef97
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
91 addition
and
109 deletion
+91
-109
src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs
src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs
+1
-1
src/Compilers/CSharp/Portable/Parser/LanguageParser.cs
src/Compilers/CSharp/Portable/Parser/LanguageParser.cs
+13
-26
src/Compilers/CSharp/Portable/PublicAPI.Unshipped.txt
src/Compilers/CSharp/Portable/PublicAPI.Unshipped.txt
+2
-2
src/Compilers/CSharp/Portable/Symbols/MethodSymbol.cs
src/Compilers/CSharp/Portable/Symbols/MethodSymbol.cs
+3
-3
src/Compilers/CSharp/Portable/Syntax/RefTypeSyntax.cs
src/Compilers/CSharp/Portable/Syntax/RefTypeSyntax.cs
+2
-2
src/Compilers/CSharp/Portable/Syntax/Syntax.xml
src/Compilers/CSharp/Portable/Syntax/Syntax.xml
+3
-3
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenReadonlyRefReturnTests.cs
...CSharp/Test/Emit/CodeGen/CodeGenReadonlyRefReturnTests.cs
+1
-1
src/Compilers/CSharp/Test/Syntax/Parsing/DeclarationParsingTests.cs
...ers/CSharp/Test/Syntax/Parsing/DeclarationParsingTests.cs
+9
-9
src/Compilers/CSharp/Test/Syntax/Parsing/ReadonlyRefReturnsTests.cs
...ers/CSharp/Test/Syntax/Parsing/ReadonlyRefReturnsTests.cs
+38
-43
src/Compilers/Core/Portable/PublicAPI.Unshipped.txt
src/Compilers/Core/Portable/PublicAPI.Unshipped.txt
+2
-2
src/Compilers/Core/Portable/Symbols/IMethodSymbol.cs
src/Compilers/Core/Portable/Symbols/IMethodSymbol.cs
+3
-3
src/Compilers/Core/Portable/Symbols/RefKind.cs
src/Compilers/Core/Portable/Symbols/RefKind.cs
+4
-4
src/Compilers/VisualBasic/Portable/Symbols/MethodSymbol.vb
src/Compilers/VisualBasic/Portable/Symbols/MethodSymbol.vb
+2
-2
src/Features/Core/Portable/MetadataAsSource/AbstractMetadataAsSourceService.WrappedMethodSymbol.cs
...ce/AbstractMetadataAsSourceService.WrappedMethodSymbol.cs
+2
-2
src/Workspaces/Core/Portable/CodeGeneration/Symbols/CodeGenerationAbstractMethodSymbol.cs
...eGeneration/Symbols/CodeGenerationAbstractMethodSymbol.cs
+1
-1
src/Workspaces/Core/Portable/CodeGeneration/Symbols/CodeGenerationConstructedMethodSymbol.cs
...neration/Symbols/CodeGenerationConstructedMethodSymbol.cs
+2
-2
src/Workspaces/Core/Portable/CodeGeneration/Symbols/CodeGenerationMethodSymbol.cs
...able/CodeGeneration/Symbols/CodeGenerationMethodSymbol.cs
+3
-3
未找到文件。
src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs
浏览文件 @
cdb3a9c7
...
...
@@ -786,7 +786,7 @@ private TypeSymbol BindVariableType(CSharpSyntaxNode declarationNode, Diagnostic
// might own nested scope.
bool
hasErrors
=
localSymbol
.
ScopeBinder
.
ValidateDeclarationNameConflictsInScope
(
localSymbol
,
diagnostics
);
if
(
localSymbol
.
RefKind
==
RefKind
.
In
)
if
(
localSymbol
.
RefKind
==
RefKind
.
RefReadOnly
)
{
var
refKeyword
=
typeSyntax
.
GetFirstToken
();
diagnostics
.
Add
(
ErrorCode
.
ERR_UnexpectedToken
,
refKeyword
.
GetLocation
(),
refKeyword
.
ToString
());
...
...
src/Compilers/CSharp/Portable/Parser/LanguageParser.cs
浏览文件 @
cdb3a9c7
...
...
@@ -1355,16 +1355,6 @@ private void ParseModifiers(SyntaxListBuilder tokens)
}
return
;
}
case
SyntaxModifier
.
ReadOnly
:
{
if
(
PeekToken
(
1
).
Kind
==
SyntaxKind
.
RefKeyword
)
{
// readonly is not a modifier in "readonly ref", since "ref" is not a modifier.
return
;
}
goto
default
;
}
default
:
{
modTok
=
this
.
EatToken
();
...
...
@@ -6308,16 +6298,14 @@ private ScanTypeFlags ScanNonArrayType(ParseTypeMode mode, out SyntaxToken lastT
{
ScanTypeFlags
result
;
// in a ref local or ref return, we treat "ref" and "readonly ref" as part of the type
if
(
this
.
CurrentToken
.
Kind
==
SyntaxKind
.
ReadOnlyKeyword
&&
this
.
PeekToken
(
1
).
Kind
==
SyntaxKind
.
RefKeyword
)
{
this
.
EatToken
();
this
.
EatToken
();
}
else
if
(
this
.
CurrentToken
.
Kind
==
SyntaxKind
.
RefKeyword
)
// in a ref local or ref return, we treat "ref" and "ref readonly" as part of the type
if
(
this
.
CurrentToken
.
Kind
==
SyntaxKind
.
RefKeyword
)
{
this
.
EatToken
();
if
(
this
.
CurrentToken
.
Kind
==
SyntaxKind
.
ReadOnlyKeyword
)
{
this
.
EatToken
();
}
}
if
(
this
.
CurrentToken
.
Kind
==
SyntaxKind
.
IdentifierToken
)
...
...
@@ -6529,21 +6517,20 @@ private enum ParseTypeMode
ParseTypeMode
mode
=
ParseTypeMode
.
Normal
,
bool
expectSizes
=
false
)
{
if
(
mode
==
ParseTypeMode
.
Normal
&&
!
expectSizes
)
if
(
mode
==
ParseTypeMode
.
Normal
&&
!
expectSizes
&&
this
.
CurrentToken
.
Kind
==
SyntaxKind
.
RefKeyword
)
{
var
refKeyword
=
this
.
EatToken
();
refKeyword
=
this
.
CheckFeatureAvailability
(
refKeyword
,
MessageID
.
IDS_FeatureRefLocalsReturns
);
SyntaxToken
readonlyKeyword
=
null
;
if
(
this
.
CurrentToken
.
Kind
==
SyntaxKind
.
ReadOnlyKeyword
&&
this
.
PeekToken
(
1
).
Kind
==
SyntaxKind
.
RefKeyword
)
if
(
this
.
CurrentToken
.
Kind
==
SyntaxKind
.
ReadOnlyKeyword
)
{
readonlyKeyword
=
this
.
EatToken
();
readonlyKeyword
=
this
.
CheckFeatureAvailability
(
readonlyKeyword
,
MessageID
.
IDS_FeatureReadonlyReferences
);
}
if
(
this
.
CurrentToken
.
Kind
==
SyntaxKind
.
RefKeyword
)
{
var
refKeyword
=
this
.
EatToken
();
var
type
=
ParseTypeCore
(
mode
,
expectSizes
);
return
this
.
CheckFeatureAvailability
(
_syntaxFactory
.
RefType
(
readonlyKeyword
,
refKeyword
,
type
),
MessageID
.
IDS_FeatureRefLocalsReturns
);
}
var
type
=
ParseTypeCore
(
mode
,
expectSizes
);
return
_syntaxFactory
.
RefType
(
refKeyword
,
readonlyKeyword
,
type
);
}
return
ParseTypeCore
(
mode
,
expectSizes
);
...
...
src/Compilers/CSharp/Portable/PublicAPI.Unshipped.txt
浏览文件 @
cdb3a9c7
...
...
@@ -115,7 +115,7 @@ Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax.ReadOnlyKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken
Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax.RefKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken
Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax.Type.get -> Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken re
adOnlyKeyword, Microsoft.CodeAnalysis.SyntaxToken ref
Keyword, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken re
fKeyword, Microsoft.CodeAnalysis.SyntaxToken readOnly
Keyword, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken refKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax.WithReadOnlyKeyword(Microsoft.CodeAnalysis.SyntaxToken readOnlyKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax.WithRefKeyword(Microsoft.CodeAnalysis.SyntaxToken refKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax
...
...
@@ -298,7 +298,7 @@ static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ParenthesizedVariableDesignat
static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.RefExpression(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefExpressionSyntax
static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.RefExpression(Microsoft.CodeAnalysis.SyntaxToken refKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefExpressionSyntax
static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.RefType(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax
static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.RefType(Microsoft.CodeAnalysis.SyntaxToken re
adOnlyKeyword, Microsoft.CodeAnalysis.SyntaxToken ref
Keyword, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax
static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.RefType(Microsoft.CodeAnalysis.SyntaxToken re
fKeyword, Microsoft.CodeAnalysis.SyntaxToken readOnly
Keyword, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax
static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.RefType(Microsoft.CodeAnalysis.SyntaxToken refKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax
static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.SingleVariableDesignation(Microsoft.CodeAnalysis.SyntaxToken identifier) -> Microsoft.CodeAnalysis.CSharp.Syntax.SingleVariableDesignationSyntax
static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ThrowExpression(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression) -> Microsoft.CodeAnalysis.CSharp.Syntax.ThrowExpressionSyntax
...
...
src/Compilers/CSharp/Portable/Symbols/MethodSymbol.cs
浏览文件 @
cdb3a9c7
...
...
@@ -181,14 +181,14 @@ public bool ReturnsByRef
}
/// <summary>
/// Indicates whether or not the method returns by re
adonly reference
/// Indicates whether or not the method returns by re
f readonly
/// </summary>
public
bool
ReturnsByRe
adonlyRef
public
bool
ReturnsByRe
fReadonly
{
get
{
Debug
.
Assert
(
this
.
RefKind
!=
RefKind
.
Out
);
return
this
.
RefKind
==
RefKind
.
In
;
return
this
.
RefKind
==
RefKind
.
RefReadOnly
;
}
}
...
...
src/Compilers/CSharp/Portable/Syntax/RefTypeSyntax.cs
浏览文件 @
cdb3a9c7
...
...
@@ -11,7 +11,7 @@ public partial class RefTypeSyntax
{
public
RefTypeSyntax
Update
(
SyntaxToken
refKeyword
,
TypeSyntax
type
)
{
return
Update
(
default
(
SyntaxToken
),
refKeyword
,
type
);
return
Update
(
refKeyword
,
default
(
SyntaxToken
)
,
type
);
}
}
}
...
...
@@ -23,7 +23,7 @@ public partial class SyntaxFactory
/// <summary>Creates a new RefTypeSyntax instance.</summary>
public
static
RefTypeSyntax
RefType
(
SyntaxToken
refKeyword
,
TypeSyntax
type
)
{
return
RefType
(
default
(
SyntaxToken
),
refKeyword
,
type
);
return
RefType
(
refKeyword
,
default
(
SyntaxToken
)
,
type
);
}
}
}
src/Compilers/CSharp/Portable/Syntax/Syntax.xml
浏览文件 @
cdb3a9c7
...
...
@@ -298,15 +298,15 @@
<summary>
The ref modifier of a method's return value or a local.
</summary>
</TypeComment>
<Kind
Name=
"RefType"
/>
<Field
Name=
"RefKeyword"
Type=
"SyntaxToken"
>
<Kind
Name=
"RefKeyword"
/>
</Field>
<Field
Name=
"ReadOnlyKeyword"
Type=
"SyntaxToken"
Optional=
"true"
>
<Kind
Name=
"ReadOnlyKeyword"
/>
<PropertyComment>
<summary>
Gets the optional "readonly" keyword.
</summary>
</PropertyComment>
</Field>
<Field
Name=
"RefKeyword"
Type=
"SyntaxToken"
>
<Kind
Name=
"RefKeyword"
/>
</Field>
<Field
Name=
"Type"
Type=
"TypeSyntax"
/>
</Node>
<!-- Expressions -->
...
...
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenReadonlyRefReturnTests.cs
浏览文件 @
cdb3a9c7
...
...
@@ -21,7 +21,7 @@ public void RefReturnArrayAccess()
var
text
=
@"
class Program
{
static re
adonly ref
int M()
static re
f readonly
int M()
{
return ref (new int[1])[0];
}
...
...
src/Compilers/CSharp/Test/Syntax/Parsing/DeclarationParsingTests.cs
浏览文件 @
cdb3a9c7
...
...
@@ -1981,7 +1981,7 @@ public void TestDelegateWithRefReturnType()
[
Fact
]
public
void
TestDelegateWithReadonlyRefReturnType
()
{
var
text
=
"delegate re
adonly ref
a b();"
;
var
text
=
"delegate re
f readonly
a b();"
;
var
file
=
this
.
ParseFile
(
text
,
TestOptions
.
Regular
);
Assert
.
NotNull
(
file
);
...
...
@@ -1993,7 +1993,7 @@ public void TestDelegateWithReadonlyRefReturnType()
var
ds
=
(
DelegateDeclarationSyntax
)
file
.
Members
[
0
];
Assert
.
NotNull
(
ds
.
DelegateKeyword
);
Assert
.
NotNull
(
ds
.
ReturnType
);
Assert
.
Equal
(
"re
adonly ref
a"
,
ds
.
ReturnType
.
ToString
());
Assert
.
Equal
(
"re
f readonly
a"
,
ds
.
ReturnType
.
ToString
());
Assert
.
NotNull
(
ds
.
Identifier
);
Assert
.
Equal
(
"b"
,
ds
.
Identifier
.
ToString
());
Assert
.
NotNull
(
ds
.
ParameterList
.
OpenParenToken
);
...
...
@@ -2498,7 +2498,7 @@ public void TestClassMethodWithRefReturn()
[
Fact
]
public
void
TestClassMethodWithReadonlyRefReturn
()
{
var
text
=
"class a { re
adonly ref
b X() { } }"
;
var
text
=
"class a { re
f readonly
b X() { } }"
;
var
file
=
this
.
ParseFile
(
text
,
TestOptions
.
Regular
);
Assert
.
NotNull
(
file
);
...
...
@@ -2525,7 +2525,7 @@ public void TestClassMethodWithReadonlyRefReturn()
var
ms
=
(
MethodDeclarationSyntax
)
cs
.
Members
[
0
];
Assert
.
Equal
(
0
,
ms
.
AttributeLists
.
Count
);
Assert
.
NotNull
(
ms
.
ReturnType
);
Assert
.
Equal
(
"re
adonly ref
b"
,
ms
.
ReturnType
.
ToString
());
Assert
.
Equal
(
"re
f readonly
b"
,
ms
.
ReturnType
.
ToString
());
Assert
.
NotNull
(
ms
.
Identifier
);
Assert
.
Equal
(
"X"
,
ms
.
Identifier
.
ToString
());
Assert
.
NotNull
(
ms
.
ParameterList
.
OpenParenToken
);
...
...
@@ -2572,7 +2572,7 @@ public void TestClassMethodWithRef()
[
Fact
]
public
void
TestClassMethodWithReadonlyRef
()
{
var
text
=
"class a { re
adonly ref
}"
;
var
text
=
"class a { re
f readonly
}"
;
var
file
=
this
.
ParseFile
(
text
,
parseOptions
:
TestOptions
.
Regular
);
Assert
.
NotNull
(
file
);
...
...
@@ -3946,7 +3946,7 @@ public void TestClassPropertyWithRefReturn()
[
Fact
]
public
void
TestClassPropertyWithReadonlyRefReturn
()
{
var
text
=
"class a { re
adonly ref
b c { get; set; } }"
;
var
text
=
"class a { re
f readonly
b c { get; set; } }"
;
var
file
=
this
.
ParseFile
(
text
,
TestOptions
.
Regular
);
Assert
.
NotNull
(
file
);
...
...
@@ -3974,7 +3974,7 @@ public void TestClassPropertyWithReadonlyRefReturn()
Assert
.
Equal
(
0
,
ps
.
AttributeLists
.
Count
);
Assert
.
Equal
(
0
,
ps
.
Modifiers
.
Count
);
Assert
.
NotNull
(
ps
.
Type
);
Assert
.
Equal
(
"re
adonly ref
b"
,
ps
.
Type
.
ToString
());
Assert
.
Equal
(
"re
f readonly
b"
,
ps
.
Type
.
ToString
());
Assert
.
NotNull
(
ps
.
Identifier
);
Assert
.
Equal
(
"c"
,
ps
.
Identifier
.
ToString
());
...
...
@@ -4889,7 +4889,7 @@ public void TestClassIndexerWithRefReturn()
[
Fact
]
public
void
TestClassIndexerWithReadonlyRefReturn
()
{
var
text
=
"class a { re
adonly ref
b this[c d] { get; set; } }"
;
var
text
=
"class a { re
f readonly
b this[c d] { get; set; } }"
;
var
file
=
this
.
ParseFile
(
text
,
TestOptions
.
Regular
);
Assert
.
NotNull
(
file
);
...
...
@@ -4917,7 +4917,7 @@ public void TestClassIndexerWithReadonlyRefReturn()
Assert
.
Equal
(
0
,
ps
.
AttributeLists
.
Count
);
Assert
.
Equal
(
0
,
ps
.
Modifiers
.
Count
);
Assert
.
NotNull
(
ps
.
Type
);
Assert
.
Equal
(
"re
adonly ref
b"
,
ps
.
Type
.
ToString
());
Assert
.
Equal
(
"re
f readonly
b"
,
ps
.
Type
.
ToString
());
Assert
.
NotNull
(
ps
.
ThisKeyword
);
Assert
.
Equal
(
"this"
,
ps
.
ThisKeyword
.
ToString
());
...
...
src/Compilers/CSharp/Test/Syntax/Parsing/ReadonlyRefReturnsTests.cs
浏览文件 @
cdb3a9c7
...
...
@@ -25,35 +25,33 @@ public void ReadonlyRefReturn_CSharp7()
var
text
=
@"
unsafe class Program
{
delegate re
adonly ref
int D1();
delegate re
f readonly
int D1();
static re
adonly ref
T M<T>()
static re
f readonly
T M<T>()
{
return ref (new T[1])[0];
}
public virtual re
adonly ref
int* P1 => throw null;
public virtual re
f readonly
int* P1 => throw null;
public re
adonly ref
int[][] this[int i] => throw null;
public re
f readonly
int[][] this[int i] => throw null;
}
"
;
var
comp
=
CreateCompilationWithMscorlib45
(
text
,
parseOptions
:
TestOptions
.
Regular
.
WithLanguageVersion
(
LanguageVersion
.
CSharp7
),
options
:
TestOptions
.
UnsafeDebugDll
);
comp
.
VerifyDiagnostics
(
// (4,14): error CS8107: Feature 'readonly references' is not available in C# 7. Please use language version 71 or greater.
// delegate readonly ref int D1();
Diagnostic
(
ErrorCode
.
ERR_FeatureNotAvailableInVersion7
,
"readonly"
).
WithArguments
(
"readonly references"
,
"71"
).
WithLocation
(
4
,
14
),
// (6,12): error CS8107: Feature 'readonly references' is not available in C# 7. Please use language version 71 or greater.
// static readonly ref T M<T>()
Diagnostic
(
ErrorCode
.
ERR_FeatureNotAvailableInVersion7
,
"readonly"
).
WithArguments
(
"readonly references"
,
"71"
).
WithLocation
(
6
,
12
),
// (11,20): error CS8107: Feature 'readonly references' is not available in C# 7. Please use language version 71 or greater.
// public virtual readonly ref int* P1 => throw null;
Diagnostic
(
ErrorCode
.
ERR_FeatureNotAvailableInVersion7
,
"readonly"
).
WithArguments
(
"readonly references"
,
"71"
).
WithLocation
(
11
,
20
),
// (13,12): error CS8107: Feature 'readonly references' is not available in C# 7. Please use language version 71 or greater.
// public readonly ref int[][] this[int i] => throw null;
Diagnostic
(
ErrorCode
.
ERR_FeatureNotAvailableInVersion7
,
"readonly"
).
WithArguments
(
"readonly references"
,
"71"
).
WithLocation
(
13
,
12
)
);
// (4,18): error CS8107: Feature 'readonly references' is not available in C# 7. Please use language version 71 or greater.
// delegate ref readonly int D1();
Diagnostic
(
ErrorCode
.
ERR_FeatureNotAvailableInVersion7
,
"readonly"
).
WithArguments
(
"readonly references"
,
"71"
).
WithLocation
(
4
,
18
),
// (6,16): error CS8107: Feature 'readonly references' is not available in C# 7. Please use language version 71 or greater.
// static ref readonly T M<T>()
Diagnostic
(
ErrorCode
.
ERR_FeatureNotAvailableInVersion7
,
"readonly"
).
WithArguments
(
"readonly references"
,
"71"
).
WithLocation
(
6
,
16
),
// (11,24): error CS8107: Feature 'readonly references' is not available in C# 7. Please use language version 71 or greater.
// public virtual ref readonly int* P1 => throw null;
Diagnostic
(
ErrorCode
.
ERR_FeatureNotAvailableInVersion7
,
"readonly"
).
WithArguments
(
"readonly references"
,
"71"
).
WithLocation
(
11
,
24
),
// (13,16): error CS8107: Feature 'readonly references' is not available in C# 7. Please use language version 71 or greater.
// public ref readonly int[][] this[int i] => throw null;
Diagnostic
(
ErrorCode
.
ERR_FeatureNotAvailableInVersion7
,
"readonly"
).
WithArguments
(
"readonly references"
,
"71"
).
WithLocation
(
13
,
16
));
}
[
Fact
]
...
...
@@ -67,36 +65,36 @@ static void Main()
{
}
re
adonly ref
int Field;
re
f readonly
int Field;
public static re
adonly ref
Program operator +(Program x, Program y)
public static re
f readonly
Program operator +(Program x, Program y)
{
throw null;
}
// this parses fine
static async re
adonly ref
Task M<T>()
static async re
f readonly
Task M<T>()
{
throw null;
}
public re
adonly ref
virtual int* P1 => throw null;
public re
f readonly
virtual int* P1 => throw null;
}
"
;
ParseAndValidate
(
text
,
TestOptions
.
Regular
,
// (9,27): error CS1003: Syntax error, '(' expected
// re
adonly ref
int Field;
// re
f readonly
int Field;
Diagnostic
(
ErrorCode
.
ERR_SyntaxError
,
";"
).
WithArguments
(
"("
,
";"
).
WithLocation
(
9
,
27
),
// (9,27): error CS1026: ) expected
// re
adonly ref
int Field;
// re
f readonly
int Field;
Diagnostic
(
ErrorCode
.
ERR_CloseParenExpected
,
";"
).
WithLocation
(
9
,
27
),
// (11,41): error CS1519: Invalid token 'operator' in class, struct, or interface member declaration
// public static re
adonly ref
Program operator +(Program x, Program y)
// public static re
f readonly
Program operator +(Program x, Program y)
Diagnostic
(
ErrorCode
.
ERR_InvalidMemberDecl
,
"operator"
).
WithArguments
(
"operator"
).
WithLocation
(
11
,
41
),
// (11,41): error CS1519: Invalid token 'operator' in class, struct, or interface member declaration
// public static re
adonly ref
Program operator +(Program x, Program y)
// public static re
f readonly
Program operator +(Program x, Program y)
Diagnostic
(
ErrorCode
.
ERR_InvalidMemberDecl
,
"operator"
).
WithArguments
(
"operator"
).
WithLocation
(
11
,
41
),
// (12,5): error CS1519: Invalid token '{' in class, struct, or interface member declaration
// {
...
...
@@ -105,12 +103,11 @@ static void Main()
// {
Diagnostic
(
ErrorCode
.
ERR_InvalidMemberDecl
,
"{"
).
WithArguments
(
"{"
).
WithLocation
(
12
,
5
),
// (22,25): error CS1031: Type expected
// public re
adonly ref
virtual int* P1 => throw null;
// public re
f readonly
virtual int* P1 => throw null;
Diagnostic
(
ErrorCode
.
ERR_TypeExpected
,
"virtual"
).
WithLocation
(
22
,
25
),
// (24,1): error CS1022: Type or namespace definition, or end-of-file expected
// }
Diagnostic
(
ErrorCode
.
ERR_EOFExpected
,
"}"
).
WithLocation
(
24
,
1
)
);
Diagnostic
(
ErrorCode
.
ERR_EOFExpected
,
"}"
).
WithLocation
(
24
,
1
));
}
[
Fact
]
...
...
@@ -122,11 +119,11 @@ class Program
{
static void Main()
{
re
adonly ref
int local = ref (new int[1])[0];
re
f readonly
int local = ref (new int[1])[0];
(re
adonly ref int, readonly ref
int Alice)? t = null;
(re
f readonly int, ref readonly
int Alice)? t = null;
System.Collections.Generic.List<re
adonly ref
int> x = null;
System.Collections.Generic.List<re
f readonly
int> x = null;
Use(local);
Use(t);
...
...
@@ -142,17 +139,15 @@ static void Use<T>(T dummy)
var
comp
=
CreateCompilationWithMscorlib45
(
text
,
new
[]
{
ValueTupleRef
,
SystemRuntimeFacadeRef
});
comp
.
VerifyDiagnostics
(
// (9,19): error CS1073: Unexpected token 'ref'
// (readonly ref int, readonly ref int Alice)? t = null;
Diagnostic
(
ErrorCode
.
ERR_UnexpectedToken
,
"ref"
).
WithArguments
(
"ref"
).
WithLocation
(
9
,
19
),
// (9,37): error CS1073: Unexpected token 'ref'
// (readonly ref int, readonly ref int Alice)? t = null;
Diagnostic
(
ErrorCode
.
ERR_UnexpectedToken
,
"ref"
).
WithArguments
(
"ref"
).
WithLocation
(
9
,
37
),
// (11,50): error CS1073: Unexpected token 'ref'
// System.Collections.Generic.List<readonly ref int> x = null;
Diagnostic
(
ErrorCode
.
ERR_UnexpectedToken
,
"ref"
).
WithArguments
(
"ref"
).
WithLocation
(
11
,
50
)
);
// (9,10): error CS1073: Unexpected token 'ref'
// (ref readonly int, ref readonly int Alice)? t = null;
Diagnostic
(
ErrorCode
.
ERR_UnexpectedToken
,
"ref"
).
WithArguments
(
"ref"
).
WithLocation
(
9
,
10
),
// (9,28): error CS1073: Unexpected token 'ref'
// (ref readonly int, ref readonly int Alice)? t = null;
Diagnostic
(
ErrorCode
.
ERR_UnexpectedToken
,
"ref"
).
WithArguments
(
"ref"
).
WithLocation
(
9
,
28
),
// (11,41): error CS1073: Unexpected token 'ref'
// System.Collections.Generic.List<ref readonly int> x = null;
Diagnostic
(
ErrorCode
.
ERR_UnexpectedToken
,
"ref"
).
WithArguments
(
"ref"
).
WithLocation
(
11
,
41
));
}
}
}
src/Compilers/Core/Portable/PublicAPI.Unshipped.txt
浏览文件 @
cdb3a9c7
...
...
@@ -93,7 +93,7 @@ Microsoft.CodeAnalysis.IDiscardSymbol.Type.get -> Microsoft.CodeAnalysis.ITypeSy
Microsoft.CodeAnalysis.IFieldSymbol.CorrespondingTupleField.get -> Microsoft.CodeAnalysis.IFieldSymbol
Microsoft.CodeAnalysis.ILocalSymbol.IsRef.get -> bool
Microsoft.CodeAnalysis.IMethodSymbol.RefCustomModifiers.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.CustomModifier>
Microsoft.CodeAnalysis.IMethodSymbol.ReturnsByRe
adonlyRef
.get -> bool
Microsoft.CodeAnalysis.IMethodSymbol.ReturnsByRe
fReadonly
.get -> bool
Microsoft.CodeAnalysis.IMethodSymbol.ReturnsByRef.get -> bool
Microsoft.CodeAnalysis.INamedTypeSymbol.GetTypeArgumentCustomModifiers(int ordinal) -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.CustomModifier>
Microsoft.CodeAnalysis.INamedTypeSymbol.IsComImport.get -> bool
...
...
@@ -190,7 +190,7 @@ Microsoft.CodeAnalysis.OperationKind.WithStatement = 82 -> Microsoft.CodeAnalysi
Microsoft.CodeAnalysis.OperationKind.YieldBreakStatement = 12 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.YieldReturnStatement = 16 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.PortableExecutableReference.GetMetadataId() -> Microsoft.CodeAnalysis.MetadataId
Microsoft.CodeAnalysis.RefKind.
In
= 3 -> Microsoft.CodeAnalysis.RefKind
Microsoft.CodeAnalysis.RefKind.
RefReadOnly
= 3 -> Microsoft.CodeAnalysis.RefKind
Microsoft.CodeAnalysis.SemanticModel.GetOperation(Microsoft.CodeAnalysis.SyntaxNode node, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Semantics.ArgumentKind
Microsoft.CodeAnalysis.Semantics.ArgumentKind.DefaultValue = 4 -> Microsoft.CodeAnalysis.Semantics.ArgumentKind
...
...
src/Compilers/Core/Portable/Symbols/IMethodSymbol.cs
浏览文件 @
cdb3a9c7
...
...
@@ -75,11 +75,11 @@ public interface IMethodSymbol : ISymbol
/// </summary>
bool
ReturnsByRef
{
get
;
}
// PROTOTYPE(re
adonlyRef
): this is very preliminary. We need to have _some_ API for now.
// PROTOTYPE(re
freadonly
): this is very preliminary. We need to have _some_ API for now.
/// <summary>
/// Returns true if this method returns by re
adonly reference
.
/// Returns true if this method returns by re
f readonly
.
/// </summary>
bool
ReturnsByRe
adonlyRef
{
get
;
}
bool
ReturnsByRe
fReadonly
{
get
;
}
/// <summary>
/// Gets the return type of the method.
...
...
src/Compilers/Core/Portable/Symbols/RefKind.cs
浏览文件 @
cdb3a9c7
...
...
@@ -25,9 +25,9 @@ public enum RefKind : byte
Out
=
2
,
/// <summary>
/// Indicates an "in" parameter.
/// Indicates a
"ref readonly" or a
n "in" parameter.
/// </summary>
In
=
3
,
RefReadOnly
=
3
,
}
internal
static
class
RefKindExtensions
...
...
@@ -38,7 +38,7 @@ internal static string ToDisplayString(this RefKind kind)
{
case
RefKind
.
Out
:
return
"out"
;
case
RefKind
.
Ref
:
return
"ref"
;
case
RefKind
.
In
:
return
"in
"
;
case
RefKind
.
RefReadOnly
:
return
"ref readonly
"
;
default
:
return
null
;
}
}
...
...
@@ -49,7 +49,7 @@ internal static string ToPrefix(this RefKind kind)
{
case
RefKind
.
Out
:
return
"out "
;
case
RefKind
.
Ref
:
return
"ref "
;
case
RefKind
.
In
:
return
"in
"
;
case
RefKind
.
RefReadOnly
:
return
"ref readonly
"
;
default
:
return
string
.
Empty
;
}
}
...
...
src/Compilers/VisualBasic/Portable/Symbols/MethodSymbol.vb
浏览文件 @
cdb3a9c7
...
...
@@ -949,9 +949,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
End
Get
End
Property
Private
ReadOnly
Property
IMethodSymbol_ReturnsByRe
adonlyRef
As
Boolean
Implements
IMethodSymbol
.
ReturnsByReadonlyRef
Private
ReadOnly
Property
IMethodSymbol_ReturnsByRe
fReadonly
As
Boolean
Implements
IMethodSymbol
.
ReturnsByRefReadonly
Get
' PROTOTYPE(re
adonlyRef
): NYI
' PROTOTYPE(re
freadonly
): NYI
Return
False
End
Get
End
Property
...
...
src/Features/Core/Portable/MetadataAsSource/AbstractMetadataAsSourceService.WrappedMethodSymbol.cs
浏览文件 @
cdb3a9c7
...
...
@@ -178,11 +178,11 @@ public bool ReturnsByRef
}
}
public
bool
ReturnsByRe
adonlyRef
public
bool
ReturnsByRe
fReadonly
{
get
{
return
_symbol
.
ReturnsByRe
adonlyRef
;
return
_symbol
.
ReturnsByRe
fReadonly
;
}
}
...
...
src/Workspaces/Core/Portable/CodeGeneration/Symbols/CodeGenerationAbstractMethodSymbol.cs
浏览文件 @
cdb3a9c7
...
...
@@ -32,7 +32,7 @@ public virtual ImmutableArray<AttributeData> GetReturnTypeAttributes()
public
abstract
int
Arity
{
get
;
}
public
abstract
bool
ReturnsVoid
{
get
;
}
public
abstract
bool
ReturnsByRef
{
get
;
}
public
abstract
bool
ReturnsByRe
adonlyRef
{
get
;
}
public
abstract
bool
ReturnsByRe
fReadonly
{
get
;
}
public
abstract
ITypeSymbol
ReturnType
{
get
;
}
public
abstract
ImmutableArray
<
ITypeSymbol
>
TypeArguments
{
get
;
}
public
abstract
ImmutableArray
<
ITypeParameterSymbol
>
TypeParameters
{
get
;
}
...
...
src/Workspaces/Core/Portable/CodeGeneration/Symbols/CodeGenerationConstructedMethodSymbol.cs
浏览文件 @
cdb3a9c7
...
...
@@ -48,11 +48,11 @@ public override bool ReturnsByRef
}
}
public
override
bool
ReturnsByRe
adonlyRef
public
override
bool
ReturnsByRe
fReadonly
{
get
{
return
_constructedFrom
.
ReturnsByRe
adonlyRef
;
return
_constructedFrom
.
ReturnsByRe
fReadonly
;
}
}
...
...
src/Workspaces/Core/Portable/CodeGeneration/Symbols/CodeGenerationMethodSymbol.cs
浏览文件 @
cdb3a9c7
...
...
@@ -33,7 +33,7 @@ internal partial class CodeGenerationMethodSymbol : CodeGenerationAbstractMethod
:
base
(
containingType
,
attributes
,
declaredAccessibility
,
modifiers
,
name
,
returnTypeAttributes
)
{
_returnType
=
returnType
;
// PROTOTYPE(re
adonlyRef
): NYI
// PROTOTYPE(re
freadonly
): NYI
_refKind
=
returnsByRef
?
RefKind
.
Ref
:
RefKind
.
None
;
_typeParameters
=
typeParameters
.
AsImmutableOrEmpty
();
_parameters
=
parameters
.
AsImmutableOrEmpty
();
...
...
@@ -119,11 +119,11 @@ public override bool ReturnsByRef
}
}
public
override
bool
ReturnsByRe
adonlyRef
public
override
bool
ReturnsByRe
fReadonly
{
get
{
return
_refKind
==
RefKind
.
In
;
return
_refKind
==
RefKind
.
RefReadOnly
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录