Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
56ce0562
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,发现更多精彩内容 >>
未验证
提交
56ce0562
编写于
6月 03, 2020
作者:
C
Charles Stoner
提交者:
GitHub
6月 03, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use inherited properties for records (#44705)
上级
eebb3e44
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
993 addition
and
69 deletion
+993
-69
src/Compilers/CSharp/Portable/Symbols/MemberSymbolExtensions.cs
...mpilers/CSharp/Portable/Symbols/MemberSymbolExtensions.cs
+1
-0
src/Compilers/CSharp/Portable/Symbols/OverriddenOrHiddenMembersHelpers.cs
...harp/Portable/Symbols/OverriddenOrHiddenMembersHelpers.cs
+1
-1
src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberContainerSymbol.cs
...rp/Portable/Symbols/Source/SourceMemberContainerSymbol.cs
+33
-5
src/Compilers/CSharp/Portable/Symbols/Source/SourceOrRecordPropertySymbol.cs
...p/Portable/Symbols/Source/SourceOrRecordPropertySymbol.cs
+0
-1
src/Compilers/CSharp/Portable/Symbols/Synthesized/Records/SynthesizedRecordGetHashCode.cs
...mbols/Synthesized/Records/SynthesizedRecordGetHashCode.cs
+2
-4
src/Compilers/CSharp/Portable/Symbols/Synthesized/Records/SynthesizedRecordObjEquals.cs
...Symbols/Synthesized/Records/SynthesizedRecordObjEquals.cs
+2
-3
src/Compilers/CSharp/Portable/Symbols/Synthesized/Records/SynthesizedRecordPropertySymbol.cs
...ls/Synthesized/Records/SynthesizedRecordPropertySymbol.cs
+0
-3
src/Compilers/CSharp/Test/Semantic/Semantics/RecordTests.cs
src/Compilers/CSharp/Test/Semantic/Semantics/RecordTests.cs
+954
-52
未找到文件。
src/Compilers/CSharp/Portable/Symbols/MemberSymbolExtensions.cs
浏览文件 @
56ce0562
...
...
@@ -102,6 +102,7 @@ internal static int GetParameterCount(this Symbol member)
case
SymbolKind
.
Property
:
return
((
PropertySymbol
)
member
).
ParameterCount
;
case
SymbolKind
.
Event
:
case
SymbolKind
.
Field
:
return
0
;
default
:
throw
ExceptionUtilities
.
UnexpectedValue
(
member
.
Kind
);
...
...
src/Compilers/CSharp/Portable/Symbols/OverriddenOrHiddenMembersHelpers.cs
浏览文件 @
56ce0562
...
...
@@ -473,7 +473,7 @@ internal static OverriddenOrHiddenMembersResult MakeInterfaceOverriddenOrHiddenM
///
/// In incorrect or imported code, it is possible that both currTypeBestMatch and hiddenBuilder will be populated.
/// </remarks>
private
static
void
FindOverriddenOrHiddenMembersInType
(
internal
static
void
FindOverriddenOrHiddenMembersInType
(
Symbol
member
,
bool
memberIsFromSomeCompilation
,
NamedTypeSymbol
memberContainingType
,
...
...
src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberContainerSymbol.cs
浏览文件 @
56ce0562
...
...
@@ -2933,11 +2933,13 @@ private void AddSynthesizedRecordMembersIfNecessary(MembersAndInitializersBuilde
return
;
}
// PROTOTYPE: need to check base members as well
var
memberSignatures
=
s_duplicateMemberSignatureDictionary
.
Allocate
();
foreach
(
var
member
in
members
)
{
memberSignatures
.
Add
(
member
,
member
);
if
(!
memberSignatures
.
ContainsKey
(
member
))
{
memberSignatures
.
Add
(
member
,
member
);
}
}
// Positional record
...
...
@@ -3006,7 +3008,8 @@ void addProperties(ImmutableArray<ParameterSymbol> recordParameters)
foreach
(
ParameterSymbol
param
in
recordParameters
)
{
var
property
=
new
SynthesizedRecordPropertySymbol
(
this
,
param
,
diagnostics
);
if
(!
memberSignatures
.
ContainsKey
(
property
))
if
(!
memberSignatures
.
ContainsKey
(
property
)
&&
!
hidesInheritedMember
(
property
,
this
))
{
members
.
Add
(
property
);
members
.
Add
(
property
.
GetMethod
);
...
...
@@ -3016,12 +3019,37 @@ void addProperties(ImmutableArray<ParameterSymbol> recordParameters)
}
}
static
bool
hidesInheritedMember
(
Symbol
symbol
,
NamedTypeSymbol
type
)
{
while
((
type
=
type
.
BaseTypeNoUseSiteDiagnostics
)
is
object
)
{
OverriddenOrHiddenMembersHelpers
.
FindOverriddenOrHiddenMembersInType
(
symbol
,
memberIsFromSomeCompilation
:
true
,
memberContainingType
:
symbol
.
ContainingType
,
currType
:
type
,
out
var
bestMatch
,
out
bool
hasSameKindNonMatch
,
out
var
hiddenBuilder
);
if
(
hiddenBuilder
is
object
)
{
hiddenBuilder
.
Free
();
return
true
;
}
if
(
bestMatch
is
object
)
{
return
true
;
}
}
return
false
;
}
void
addObjectEquals
(
MethodSymbol
thisEquals
)
{
var
objEquals
=
new
SynthesizedRecordObjEquals
(
this
,
thisEquals
);
if
(!
memberSignatures
.
ContainsKey
(
objEquals
))
{
//
PROTOTYPE
: Don't add if the overridden method is sealed
//
https://github.com/dotnet/roslyn/issues/44617
: Don't add if the overridden method is sealed
members
.
Add
(
objEquals
);
}
}
...
...
@@ -3031,7 +3059,7 @@ void addHashCode()
var
hashCode
=
new
SynthesizedRecordGetHashCode
(
this
);
if
(!
memberSignatures
.
ContainsKey
(
hashCode
))
{
//
PROTOTYPE
: Don't add if the overridden method is sealed
//
https://github.com/dotnet/roslyn/issues/44617
: Don't add if the overridden method is sealed
members
.
Add
(
hashCode
);
}
}
...
...
src/Compilers/CSharp/Portable/Symbols/Source/SourceOrRecordPropertySymbol.cs
浏览文件 @
56ce0562
...
...
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using
Microsoft.CodeAnalysis.CSharp.Syntax
;
namespace
Microsoft.CodeAnalysis.CSharp.Symbols
...
...
src/Compilers/CSharp/Portable/Symbols/Synthesized/Records/SynthesizedRecordGetHashCode.cs
浏览文件 @
56ce0562
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System
;
...
...
@@ -10,7 +9,6 @@
using
System.Collections.Immutable
;
using
System.Reflection
;
using
Microsoft.Cci
;
using
Microsoft.CodeAnalysis.PooledObjects
;
namespace
Microsoft.CodeAnalysis.CSharp.Symbols
{
...
...
@@ -118,4 +116,4 @@ internal override void GenerateMethodBody(TypeCompilationState compilationState,
F
.
CloseMethod
(
F
.
Return
(
F
.
Literal
(
0
)));
}
}
}
\ No newline at end of file
}
src/Compilers/CSharp/Portable/Symbols/Synthesized/Records/SynthesizedRecordObjEquals.cs
浏览文件 @
56ce0562
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
...
...
@@ -20,7 +20,6 @@ internal sealed class SynthesizedRecordObjEquals : SynthesizedInstanceMethodSymb
public
override
ImmutableArray
<
ParameterSymbol
>
Parameters
{
get
;
}
public
SynthesizedRecordObjEquals
(
NamedTypeSymbol
containingType
,
MethodSymbol
typedRecordEquals
)
{
_typedRecordEquals
=
typedRecordEquals
;
...
...
@@ -152,4 +151,4 @@ internal override void GenerateMethodBody(TypeCompilationState compilationState,
F
.
CloseMethod
(
F
.
Block
(
ImmutableArray
.
Create
<
BoundStatement
>(
F
.
Return
(
expression
))));
}
}
}
\ No newline at end of file
}
src/Compilers/CSharp/Portable/Symbols/Synthesized/Records/SynthesizedRecordPropertySymbol.cs
浏览文件 @
56ce0562
...
...
@@ -2,17 +2,14 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Immutable
;
using
System.Reflection
;
using
System.Text
;
using
Microsoft.Cci
;
using
Microsoft.CodeAnalysis.CSharp.Syntax
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.CSharp.Symbols
{
...
...
src/Compilers/CSharp/Test/Semantic/Semantics/RecordTests.cs
浏览文件 @
56ce0562
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录