Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
runtime
提交
a56b1066
R
runtime
项目概览
dotNET Platform
/
runtime
11 个月 前同步成功
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
runtime
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
a56b1066
编写于
3月 26, 2022
作者:
T
Theodore Tsirpanis
提交者:
GitHub
3月 26, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use generic `Enum` methods in more places. (#67147)
上级
a2448b02
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
29 addition
and
17 deletion
+29
-17
src/libraries/Common/src/Interop/Unix/System.Native/Interop.MountPoints.FormatInfo.cs
...erop/Unix/System.Native/Interop.MountPoints.FormatInfo.cs
+1
-1
src/libraries/System.Data.Common/src/System/Xml/XPathNodePointer.cs
...ies/System.Data.Common/src/System/Xml/XPathNodePointer.cs
+2
-2
src/libraries/System.Data.OleDb/src/OleDbConnectionStringBuilder.cs
...ies/System.Data.OleDb/src/OleDbConnectionStringBuilder.cs
+6
-6
src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/PerformanceData/PerfProviderCollection.cs
...tem/Diagnostics/PerformanceData/PerfProviderCollection.cs
+2
-2
src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.cs
....IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.cs
+1
-1
src/libraries/System.IO.Packaging/src/System/IO/Packaging/InternalRelationshipCollection.cs
...src/System/IO/Packaging/InternalRelationshipCollection.cs
+4
-0
src/libraries/System.Net.Security/src/System/Net/Security/TlsCipherSuiteData.cs
...et.Security/src/System/Net/Security/TlsCipherSuiteData.cs
+2
-3
src/libraries/System.Private.Xml/src/System/Xml/Xsl/XmlQueryTypeFactory.cs
...tem.Private.Xml/src/System/Xml/Xsl/XmlQueryTypeFactory.cs
+2
-2
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/EnumConverter.cs
...Text/Json/Serialization/Converters/Value/EnumConverter.cs
+9
-0
未找到文件。
src/libraries/Common/src/Interop/Unix/System.Native/Interop.MountPoints.FormatInfo.cs
浏览文件 @
a56b1066
...
...
@@ -12,7 +12,7 @@ internal static partial class Sys
#if DEBUG
static
Sys
()
{
foreach
(
string
name
in
Enum
.
GetNames
(
typeof
(
UnixFileSystemTypes
)
))
foreach
(
string
name
in
Enum
.
GetNames
<
UnixFileSystemTypes
>(
))
{
System
.
Diagnostics
.
Debug
.
Assert
(
GetDriveType
(
name
)
!=
DriveType
.
Unknown
,
$"Expected
{
nameof
(
UnixFileSystemTypes
)}
.
{
name
}
to have an entry in
{
nameof
(
GetDriveType
)}
."
);
...
...
src/libraries/System.Data.Common/src/System/Xml/XPathNodePointer.cs
浏览文件 @
a56b1066
...
...
@@ -28,10 +28,10 @@ private static int[] CreateXmlNodeTypeToXpathNodeTypeMap()
{
#if DEBUG
int
max
=
0
,
tempVal
=
0
;
Array
enumValues
=
Enum
.
GetValues
(
typeof
(
XmlNodeType
)
);
XmlNodeType
[]
enumValues
=
Enum
.
GetValues
<
XmlNodeType
>(
);
for
(
int
i
=
0
;
i
<
enumValues
.
Length
;
i
++)
{
tempVal
=
(
int
)
enumValues
.
GetValue
(
i
)!
;
tempVal
=
(
int
)
enumValues
[
i
]
;
if
(
tempVal
>
max
)
max
=
tempVal
;
}
...
...
src/libraries/System.Data.OleDb/src/OleDbConnectionStringBuilder.cs
浏览文件 @
a56b1066
...
...
@@ -632,13 +632,13 @@ public override bool CanConvertFrom(ITypeDescriptorContext? context, Type source
string
[]
values
=
svalue
.
Split
(
new
char
[]
{
','
});
foreach
(
string
v
in
values
)
{
convertedValue
|=
(
int
)
(
OleDbServiceValues
)
Enum
.
Parse
(
typeof
(
OleDbServiceValues
),
v
,
true
);
convertedValue
|=
(
int
)
Enum
.
Parse
<
OleDbServiceValues
>(
v
,
true
);
}
return
(
int
)
convertedValue
;
return
convertedValue
;
}
else
{
return
(
int
)
(
OleDbServiceValues
)
Enum
.
Parse
(
typeof
(
OleDbServiceValues
),
svalue
,
true
);
return
(
int
)
Enum
.
Parse
<
OleDbServiceValues
>(
svalue
,
true
);
}
}
}
...
...
@@ -651,11 +651,11 @@ public override bool CanConvertTo(ITypeDescriptorContext? context, [NotNullWhen(
return
((
typeof
(
string
)
==
destinationType
)
||
base
.
CanConvertTo
(
context
,
destinationType
));
}
public
override
object
?
ConvertTo
(
ITypeDescriptorContext
?
context
,
System
.
Globalization
.
CultureInfo
?
culture
,
object
?
value
,
Type
destinationType
)
public
override
object
?
ConvertTo
(
ITypeDescriptorContext
?
context
,
CultureInfo
?
culture
,
object
?
value
,
Type
destinationType
)
{
if
((
typeof
(
string
)
==
destinationType
)
&&
(
null
!=
value
)
&&
(
typeof
(
int
)
==
value
.
GetType
()))
{
return
Enum
.
Format
(
typeof
(
OleDbServiceValues
),
((
OleDbServiceValues
)(
int
)
value
),
"G"
);
return
((
OleDbServiceValues
)(
int
)(
value
)).
ToString
(
"G"
);
}
return
base
.
ConvertTo
(
context
,
culture
,
value
,
destinationType
);
}
...
...
@@ -675,7 +675,7 @@ public override StandardValuesCollection GetStandardValues(ITypeDescriptorContex
StandardValuesCollection
?
standardValues
=
_standardValues
;
if
(
null
==
standardValues
)
{
Array
objValues
=
Enum
.
GetValues
(
typeof
(
OleDbServiceValues
)
);
OleDbServiceValues
[]
objValues
=
Enum
.
GetValues
<
OleDbServiceValues
>(
);
Array
.
Sort
(
objValues
,
0
,
objValues
.
Length
);
standardValues
=
new
StandardValuesCollection
(
objValues
);
_standardValues
=
standardValues
;
...
...
src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/PerformanceData/PerfProviderCollection.cs
浏览文件 @
a56b1066
...
...
@@ -33,8 +33,8 @@ internal static class PerfProviderCollection
private
static
object
s_hiddenInternalSyncObject
;
private
static
readonly
List
<
PerfProvider
>
s_providerList
=
new
List
<
PerfProvider
>();
private
static
readonly
Dictionary
<
object
,
int
>
s_counterSetList
=
new
Dictionary
<
object
,
int
>();
private
static
readonly
CounterType
[]
s_counterTypes
=
(
CounterType
[])
Enum
.
GetValues
(
typeof
(
CounterType
)
);
private
static
readonly
CounterSetInstanceType
[]
s_counterSetInstanceTypes
=
(
CounterSetInstanceType
[])
Enum
.
GetValues
(
typeof
(
CounterSetInstanceType
)
);
private
static
readonly
CounterType
[]
s_counterTypes
=
Enum
.
GetValues
<
CounterType
>(
);
private
static
readonly
CounterSetInstanceType
[]
s_counterSetInstanceTypes
=
Enum
.
GetValues
<
CounterSetInstanceType
>(
);
private
static
object
s_lockObject
{
...
...
src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.cs
浏览文件 @
a56b1066
...
...
@@ -64,7 +64,7 @@ public partial class FileSystemWatcher : Component, ISupportInitialize
static
FileSystemWatcher
()
{
int
s_notifyFiltersValidMask
=
0
;
foreach
(
int
enumValue
in
Enum
.
GetValues
(
typeof
(
NotifyFilters
)
))
foreach
(
int
enumValue
in
Enum
.
GetValues
<
NotifyFilters
>(
))
s_notifyFiltersValidMask
|=
enumValue
;
Debug
.
Assert
(
c_notifyFiltersValidMask
==
s_notifyFiltersValidMask
,
"The NotifyFilters enum has changed. The c_notifyFiltersValidMask must be updated to reflect the values of the NotifyFilters enum."
);
}
...
...
src/libraries/System.IO.Packaging/src/System/IO/Packaging/InternalRelationshipCollection.cs
浏览文件 @
a56b1066
...
...
@@ -320,7 +320,11 @@ private void ProcessRelationshipAttributes(XmlCompatibilityReader reader)
{
try
{
#if NET6_0_OR_GREATER
relationshipTargetMode
=
Enum
.
Parse
<
TargetMode
>(
targetModeAttributeValue
,
ignoreCase
:
false
);
#else
relationshipTargetMode
=
(
TargetMode
)(
Enum
.
Parse
(
typeof
(
TargetMode
),
targetModeAttributeValue
,
ignoreCase
:
false
));
#endif
}
catch
(
ArgumentNullException
argNullEx
)
{
...
...
src/libraries/System.Net.Security/src/System/Net/Security/TlsCipherSuiteData.cs
浏览文件 @
a56b1066
...
...
@@ -23,10 +23,9 @@ static TlsCipherSuiteData()
s_tlsLookup
.
Count
==
LookupCount
,
$"Lookup dictionary was of size
{
s_tlsLookup
.
Count
}
instead of
{
LookupCount
}
"
);
foreach
(
object
?
value
in
Enum
.
GetValues
(
typeof
(
TlsCipherSuite
)
))
foreach
(
TlsCipherSuite
value
in
Enum
.
GetValues
<
TlsCipherSuite
>(
))
{
TlsCipherSuite
val
=
(
TlsCipherSuite
)
value
!;
Debug
.
Assert
(
s_tlsLookup
.
ContainsKey
(
val
),
$"No mapping found for
{
val
}
(
{(
int
)
val
}
)"
);
Debug
.
Assert
(
s_tlsLookup
.
ContainsKey
(
value
),
$"No mapping found for
{
value
}
(
{
value
:
X
}
)"
);
}
}
...
...
src/libraries/System.Private.Xml/src/System/Xml/Xsl/XmlQueryTypeFactory.cs
浏览文件 @
a56b1066
...
...
@@ -347,8 +347,8 @@ private sealed class ItemType : XmlQueryType
static
ItemType
()
{
#if DEBUG
Array
arrEnum
=
Enum
.
GetValues
(
typeof
(
XmlTypeCode
)
);
Debug
.
Assert
(
(
XmlTypeCode
)
arrEnum
.
GetValue
(
arrEnum
.
Length
-
1
)!
==
XmlTypeCode
.
DayTimeDuration
,
XmlTypeCode
[]
arrEnum
=
Enum
.
GetValues
<
XmlTypeCode
>(
);
Debug
.
Assert
(
arrEnum
[
arrEnum
.
Length
-
1
]
==
XmlTypeCode
.
DayTimeDuration
,
"DayTimeDuration is no longer the last item in XmlTypeCode. This code expects it to be."
);
#endif
...
...
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/EnumConverter.cs
浏览文件 @
a56b1066
...
...
@@ -47,8 +47,13 @@ public EnumConverter(EnumConverterOptions converterOptions, JsonNamingPolicy? na
_namingPolicy
=
namingPolicy
;
_nameCache
=
new
ConcurrentDictionary
<
ulong
,
JsonEncodedText
>();
#if NET6_0_OR_GREATER
string
[]
names
=
Enum
.
GetNames
<
T
>();
T
[]
values
=
Enum
.
GetValues
<
T
>();
#else
string
[]
names
=
Enum
.
GetNames
(
TypeToConvert
);
Array
values
=
Enum
.
GetValues
(
TypeToConvert
);
#endif
Debug
.
Assert
(
names
.
Length
==
values
.
Length
);
JavaScriptEncoder
?
encoder
=
serializerOptions
.
Encoder
;
...
...
@@ -60,7 +65,11 @@ public EnumConverter(EnumConverterOptions converterOptions, JsonNamingPolicy? na
break
;
}
#if NET6_0_OR_GREATER
T
value
=
values
[
i
];
#else
T
value
=
(
T
)
values
.
GetValue
(
i
)!;
#endif
ulong
key
=
ConvertToUInt64
(
value
);
string
name
=
names
[
i
];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录