Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
4d46f050
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,发现更多精彩内容 >>
提交
4d46f050
编写于
12月 12, 2019
作者:
J
Jared Parsons
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
PR feedback
上级
35a265cd
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
43 addition
and
36 deletion
+43
-36
src/Compilers/Core/Portable/Collections/SmallDictionary.cs
src/Compilers/Core/Portable/Collections/SmallDictionary.cs
+8
-7
src/Compilers/Core/Portable/ConstantValue.cs
src/Compilers/Core/Portable/ConstantValue.cs
+1
-1
src/Compilers/Core/Portable/Diagnostic/Diagnostic.DiagnosticWithProgrammaticSuppression.cs
...ostic/Diagnostic.DiagnosticWithProgrammaticSuppression.cs
+2
-2
src/Compilers/Core/Portable/Diagnostic/Diagnostic.cs
src/Compilers/Core/Portable/Diagnostic/Diagnostic.cs
+8
-8
src/Compilers/Core/Portable/Diagnostic/Diagnostic_SimpleDiagnostic.cs
...s/Core/Portable/Diagnostic/Diagnostic_SimpleDiagnostic.cs
+6
-6
src/Compilers/Core/Portable/Diagnostic/ExternalFileLocation.cs
...ompilers/Core/Portable/Diagnostic/ExternalFileLocation.cs
+1
-1
src/Compilers/Core/Portable/Diagnostic/LocalizableString.cs
src/Compilers/Core/Portable/Diagnostic/LocalizableString.cs
+2
-2
src/Compilers/Core/Portable/InternalUtilities/TextKeyedCache.cs
...mpilers/Core/Portable/InternalUtilities/TextKeyedCache.cs
+1
-2
src/Compilers/Core/Portable/TreeDumper.cs
src/Compilers/Core/Portable/TreeDumper.cs
+2
-2
src/Features/Core/Portable/EditAndContinue/EditSession.cs
src/Features/Core/Portable/EditAndContinue/EditSession.cs
+1
-1
src/Workspaces/Core/Portable/Shared/Extensions/LocationExtensions.cs
...ces/Core/Portable/Shared/Extensions/LocationExtensions.cs
+11
-4
未找到文件。
src/Compilers/Core/Portable/Collections/SmallDictionary.cs
浏览文件 @
4d46f050
...
...
@@ -38,7 +38,8 @@ internal sealed class SmallDictionary<K, V> : IEnumerable<KeyValuePair<K, V>>
private
AvlNode
?
_root
;
public
readonly
IEqualityComparer
<
K
>
Comparer
;
public
static
readonly
SmallDictionary
<
K
,
V
>
Empty
=
new
SmallDictionary
<
K
,
V
>(
EqualityComparer
<
K
>.
Default
);
// https://github.com/dotnet/roslyn/issues/40344
public
static
readonly
SmallDictionary
<
K
,
V
>
Empty
=
new
SmallDictionary
<
K
,
V
>(
null
!);
public
SmallDictionary
()
:
this
(
EqualityComparer
<
K
>.
Default
)
{
}
...
...
@@ -71,7 +72,7 @@ public bool TryGetValue(K key, [MaybeNullWhen(returnValue: false)] out V value)
{
if
(
_root
!=
null
)
{
return
TryGetValue
(
GetHashCode
(
key
),
key
,
out
value
);
return
TryGetValue
(
GetHashCode
(
key
),
key
,
out
value
!
);
}
value
=
default
!;
...
...
@@ -88,7 +89,7 @@ public void Add(K key, V value)
get
{
V
value
;
if
(!
TryGetValue
(
key
,
out
value
))
if
(!
TryGetValue
(
key
,
out
value
!
))
{
throw
new
KeyNotFoundException
(
$"Could not find key
{
key
}
"
);
}
...
...
@@ -105,7 +106,7 @@ public void Add(K key, V value)
public
bool
ContainsKey
(
K
key
)
{
V
value
;
return
TryGetValue
(
key
,
out
value
);
return
TryGetValue
(
key
,
out
value
!
);
}
[
Conditional
(
"DEBUG"
)]
...
...
@@ -228,7 +229,7 @@ private bool TryGetValue(int hashCode, K key, [MaybeNullWhen(returnValue: false)
return
true
;
}
return
GetFromList
(
b
.
Next
,
key
,
out
value
);
return
GetFromList
(
b
.
Next
,
key
,
out
value
!
);
}
private
bool
GetFromList
(
Node
?
next
,
K
key
,
[
MaybeNullWhen
(
returnValue
:
false
)]
out
V
value
)
...
...
@@ -527,7 +528,7 @@ public Enumerator(SmallDictionary<K, V> dict)
// left == right only if both are nulls
if
(
root
.
Left
==
root
.
Right
)
{
_next
=
dict
.
_
root
;
_next
=
root
;
}
else
{
...
...
@@ -645,7 +646,7 @@ public Enumerator(SmallDictionary<K, V> dict)
// left == right only if both are nulls
if
(
root
.
Left
==
root
.
Right
)
{
_next
=
dict
.
_
root
;
_next
=
root
;
}
else
{
...
...
src/Compilers/Core/Portable/ConstantValue.cs
浏览文件 @
4d46f050
...
...
@@ -31,7 +31,7 @@ internal enum ConstantValueTypeDiscriminator : byte
DateTime
,
}
internal
abstract
partial
class
ConstantValue
:
IEquatable
<
ConstantValue
>
internal
abstract
partial
class
ConstantValue
:
IEquatable
<
ConstantValue
?
>
{
public
abstract
ConstantValueTypeDiscriminator
Discriminator
{
get
;
}
internal
abstract
SpecialType
SpecialType
{
get
;
}
...
...
src/Compilers/Core/Portable/Diagnostic/Diagnostic.DiagnosticWithProgrammaticSuppression.cs
浏览文件 @
4d46f050
...
...
@@ -40,10 +40,10 @@ public override string Id
get
{
return
Descriptor
.
Id
;
}
}
public
override
string
?
GetMessage
(
IFormatProvider
?
formatProvider
=
null
)
public
override
string
GetMessage
(
IFormatProvider
?
formatProvider
=
null
)
=>
_originalUnsuppressedDiagnostic
.
GetMessage
(
formatProvider
);
internal
override
IReadOnlyList
<
object
>?
Arguments
internal
override
IReadOnlyList
<
object
?
>?
Arguments
{
get
{
return
_originalUnsuppressedDiagnostic
.
Arguments
;
}
}
...
...
src/Compilers/Core/Portable/Diagnostic/Diagnostic.cs
浏览文件 @
4d46f050
...
...
@@ -36,7 +36,7 @@ public abstract partial class Diagnostic : IEquatable<Diagnostic?>, IFormattable
public
static
Diagnostic
Create
(
DiagnosticDescriptor
descriptor
,
Location
location
,
params
object
[]
messageArgs
)
params
object
?
[]
messageArgs
)
{
return
Create
(
descriptor
,
location
,
null
,
null
,
messageArgs
);
}
...
...
@@ -57,7 +57,7 @@ public abstract partial class Diagnostic : IEquatable<Diagnostic?>, IFormattable
DiagnosticDescriptor
descriptor
,
Location
location
,
ImmutableDictionary
<
string
,
string
>?
properties
,
params
object
[]?
messageArgs
)
params
object
?[]
messageArgs
)
{
return
Create
(
descriptor
,
location
,
null
,
properties
,
messageArgs
);
}
...
...
@@ -78,7 +78,7 @@ public abstract partial class Diagnostic : IEquatable<Diagnostic?>, IFormattable
DiagnosticDescriptor
descriptor
,
Location
location
,
IEnumerable
<
Location
>?
additionalLocations
,
params
object
[]?
messageArgs
)
params
object
?[]
messageArgs
)
{
return
Create
(
descriptor
,
location
,
additionalLocations
,
properties
:
null
,
messageArgs
:
messageArgs
);
}
...
...
@@ -105,7 +105,7 @@ public abstract partial class Diagnostic : IEquatable<Diagnostic?>, IFormattable
Location
location
,
IEnumerable
<
Location
>?
additionalLocations
,
ImmutableDictionary
<
string
,
string
>?
properties
,
params
object
[]?
messageArgs
)
params
object
?[]
messageArgs
)
{
return
Create
(
descriptor
,
location
,
effectiveSeverity
:
descriptor
.
DefaultSeverity
,
additionalLocations
,
properties
,
messageArgs
);
}
...
...
@@ -134,7 +134,7 @@ public abstract partial class Diagnostic : IEquatable<Diagnostic?>, IFormattable
DiagnosticSeverity
effectiveSeverity
,
IEnumerable
<
Location
>?
additionalLocations
,
ImmutableDictionary
<
string
,
string
>?
properties
,
params
object
[]?
messageArgs
)
params
object
?[]
messageArgs
)
{
if
(
descriptor
==
null
)
{
...
...
@@ -300,7 +300,7 @@ internal static Diagnostic Create(DiagnosticInfo info)
/// <summary>
/// Get the culture specific text of the message.
/// </summary>
public
abstract
string
?
GetMessage
(
IFormatProvider
?
formatProvider
=
null
);
public
abstract
string
GetMessage
(
IFormatProvider
?
formatProvider
=
null
);
/// <summary>
/// Gets the default <see cref="DiagnosticSeverity"/> of the diagnostic's <see cref="DiagnosticDescriptor"/>.
...
...
@@ -466,9 +466,9 @@ internal Diagnostic WithProgrammaticSuppression(ProgrammaticSuppressionInfo prog
// compatibility
internal
virtual
int
Code
{
get
{
return
0
;
}
}
internal
virtual
IReadOnlyList
<
object
>?
Arguments
internal
virtual
IReadOnlyList
<
object
?
>?
Arguments
{
get
{
return
SpecializedCollections
.
EmptyReadOnlyList
<
object
>();
}
get
{
return
SpecializedCollections
.
EmptyReadOnlyList
<
object
?
>();
}
}
/// <summary>
...
...
src/Compilers/Core/Portable/Diagnostic/Diagnostic_SimpleDiagnostic.cs
浏览文件 @
4d46f050
...
...
@@ -23,7 +23,7 @@ internal sealed class SimpleDiagnostic : Diagnostic
private
readonly
int
_warningLevel
;
private
readonly
Location
_location
;
private
readonly
IReadOnlyList
<
Location
>
_additionalLocations
;
private
readonly
object
[]
_messageArgs
;
private
readonly
object
?
[]
_messageArgs
;
private
readonly
ImmutableDictionary
<
string
,
string
>
_properties
;
private
readonly
bool
_isSuppressed
;
...
...
@@ -33,7 +33,7 @@ internal sealed class SimpleDiagnostic : Diagnostic
int
warningLevel
,
Location
location
,
IEnumerable
<
Location
>?
additionalLocations
,
object
[]?
messageArgs
,
object
?
[]?
messageArgs
,
ImmutableDictionary
<
string
,
string
>?
properties
,
bool
isSuppressed
)
{
...
...
@@ -48,7 +48,7 @@ internal sealed class SimpleDiagnostic : Diagnostic
_warningLevel
=
warningLevel
;
_location
=
location
??
Location
.
None
;
_additionalLocations
=
additionalLocations
?.
ToImmutableArray
()
??
SpecializedCollections
.
EmptyReadOnlyList
<
Location
>();
_messageArgs
=
messageArgs
??
Array
.
Empty
<
object
>();
_messageArgs
=
messageArgs
??
Array
.
Empty
<
object
?
>();
_properties
=
properties
??
ImmutableDictionary
<
string
,
string
>.
Empty
;
_isSuppressed
=
isSuppressed
;
}
...
...
@@ -59,7 +59,7 @@ internal sealed class SimpleDiagnostic : Diagnostic
int
warningLevel
,
Location
location
,
IEnumerable
<
Location
>?
additionalLocations
,
object
[]?
messageArgs
,
object
?
[]?
messageArgs
,
ImmutableDictionary
<
string
,
string
>?
properties
,
bool
isSuppressed
=
false
)
{
...
...
@@ -87,7 +87,7 @@ public override string Id
get
{
return
_descriptor
.
Id
;
}
}
public
override
string
?
GetMessage
(
IFormatProvider
?
formatProvider
=
null
)
public
override
string
GetMessage
(
IFormatProvider
?
formatProvider
=
null
)
{
if
(
_messageArgs
.
Length
==
0
)
{
...
...
@@ -107,7 +107,7 @@ public override string Id
}
}
internal
override
IReadOnlyList
<
object
>
Arguments
internal
override
IReadOnlyList
<
object
?
>
Arguments
{
get
{
return
_messageArgs
;
}
}
...
...
src/Compilers/Core/Portable/Diagnostic/ExternalFileLocation.cs
浏览文件 @
4d46f050
...
...
@@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis
/// <summary>
/// A program location in source code.
/// </summary>
internal
sealed
class
ExternalFileLocation
:
Location
,
IEquatable
<
ExternalFileLocation
>
internal
sealed
class
ExternalFileLocation
:
Location
,
IEquatable
<
ExternalFileLocation
?
>
{
private
readonly
TextSpan
_sourceSpan
;
private
readonly
FileLinePositionSpan
_lineSpan
;
...
...
src/Compilers/Core/Portable/Diagnostic/LocalizableString.cs
浏览文件 @
4d46f050
...
...
@@ -21,7 +21,7 @@ public abstract partial class LocalizableString : IFormattable, IEquatable<Local
/// <summary>
/// Formats the value of the current instance using the optionally specified format.
/// </summary>
public
string
?
ToString
(
IFormatProvider
?
formatProvider
)
public
string
ToString
(
IFormatProvider
?
formatProvider
)
{
try
{
...
...
@@ -90,7 +90,7 @@ public bool Equals(LocalizableString? other)
/// Provides the implementation of ToString. ToString will provide a default value
/// if this method throws an exception.
/// </summary>
protected
abstract
string
?
GetText
(
IFormatProvider
?
formatProvider
);
protected
abstract
string
GetText
(
IFormatProvider
?
formatProvider
);
/// <summary>
/// Provides the implementation of GetHashCode. GetHashCode will provide a default value
...
...
src/Compilers/Core/Portable/InternalUtilities/TextKeyedCache.cs
浏览文件 @
4d46f050
...
...
@@ -113,8 +113,7 @@ public void Free()
#
endregion
// Poolable
[
return
:
MaybeNull
]
internal
T
FindItem
(
char
[]
chars
,
int
start
,
int
len
,
int
hashCode
)
internal
T
?
FindItem
(
char
[]
chars
,
int
start
,
int
len
,
int
hashCode
)
{
// get direct element reference to avoid extra range checks
ref
var
localSlot
=
ref
_localTable
[
LocalIdxFromHash
(
hashCode
)];
...
...
src/Compilers/Core/Portable/TreeDumper.cs
浏览文件 @
4d46f050
...
...
@@ -111,7 +111,7 @@ private void DoDumpCompact(TreeDumperNode node, string indent)
public
static
string
DumpXML
(
TreeDumperNode
root
,
string
?
indent
=
null
)
{
var
dumper
=
new
TreeDumper
();
dumper
.
DoDumpXML
(
root
,
string
.
Empty
,
string
.
IsNullOrEmpty
(
indent
)
?
string
.
Empty
:
indent
!
);
dumper
.
DoDumpXML
(
root
,
string
.
Empty
,
indent
??
string
.
Empty
);
return
dumper
.
_sb
.
ToString
();
}
...
...
@@ -216,7 +216,7 @@ public TreeDumperNode(string text, object? value, IEnumerable<TreeDumperNode>? c
public
TreeDumperNode
(
string
text
)
:
this
(
text
,
null
,
null
)
{
}
public
object
?
Value
{
get
;
}
public
string
?
Text
{
get
;
}
public
string
Text
{
get
;
}
public
IEnumerable
<
TreeDumperNode
>
Children
{
get
;
}
public
TreeDumperNode
this
[
string
child
]
{
...
...
src/Features/Core/Portable/EditAndContinue/EditSession.cs
浏览文件 @
4d46f050
...
...
@@ -346,7 +346,7 @@ internal async Task<ImmutableArray<ActiveStatementExceptionRegions>> GetBaseActi
case
CommittedSolution
.
DocumentState
.
OutOfSync
:
var
descriptor
=
EditAndContinueDiagnosticDescriptors
.
GetDescriptor
(
EditAndContinueErrorCode
.
DocumentIsOutOfSyncWithDebuggee
);
outOfSyncDiagnostics
.
Add
(
Diagnostic
.
Create
(
descriptor
,
Location
.
Create
(
document
.
FilePath
!,
textSpan
:
default
,
lineSpan
:
default
),
new
[]
{
document
.
FilePath
!
}));
outOfSyncDiagnostics
.
Add
(
Diagnostic
.
Create
(
descriptor
,
Location
.
Create
(
document
.
FilePath
!,
textSpan
:
default
,
lineSpan
:
default
),
new
[]
{
document
.
FilePath
}));
continue
;
default
:
...
...
src/Workspaces/Core/Portable/Shared/Extensions/LocationExtensions.cs
浏览文件 @
4d46f050
...
...
@@ -3,22 +3,29 @@
#
nullable
enable
using
System.Threading
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.Shared.Extensions
{
internal
static
class
LocationExtensions
{
public
static
SyntaxTree
GetSourceTreeOrThrow
(
this
Location
location
)
{
Contract
.
ThrowIfNull
(
location
.
SourceTree
);
return
location
.
SourceTree
;
}
public
static
SyntaxToken
FindToken
(
this
Location
location
,
CancellationToken
cancellationToken
)
=>
location
.
SourceTree
!
.
GetRoot
(
cancellationToken
).
FindToken
(
location
.
SourceSpan
.
Start
);
=>
location
.
GetSourceTreeOrThrow
()
.
GetRoot
(
cancellationToken
).
FindToken
(
location
.
SourceSpan
.
Start
);
public
static
SyntaxNode
FindNode
(
this
Location
location
,
CancellationToken
cancellationToken
)
=>
location
.
SourceTree
!
.
GetRoot
(
cancellationToken
).
FindNode
(
location
.
SourceSpan
);
=>
location
.
GetSourceTreeOrThrow
()
.
GetRoot
(
cancellationToken
).
FindNode
(
location
.
SourceSpan
);
public
static
SyntaxNode
FindNode
(
this
Location
location
,
bool
getInnermostNodeForTie
,
CancellationToken
cancellationToken
)
=>
location
.
SourceTree
!
.
GetRoot
(
cancellationToken
).
FindNode
(
location
.
SourceSpan
,
getInnermostNodeForTie
:
getInnermostNodeForTie
);
=>
location
.
GetSourceTreeOrThrow
()
.
GetRoot
(
cancellationToken
).
FindNode
(
location
.
SourceSpan
,
getInnermostNodeForTie
:
getInnermostNodeForTie
);
public
static
SyntaxNode
FindNode
(
this
Location
location
,
bool
findInsideTrivia
,
bool
getInnermostNodeForTie
,
CancellationToken
cancellationToken
)
=>
location
.
SourceTree
!
.
GetRoot
(
cancellationToken
).
FindNode
(
location
.
SourceSpan
,
findInsideTrivia
,
getInnermostNodeForTie
);
=>
location
.
GetSourceTreeOrThrow
()
.
GetRoot
(
cancellationToken
).
FindNode
(
location
.
SourceSpan
,
findInsideTrivia
,
getInnermostNodeForTie
);
public
static
bool
IsVisibleSourceLocation
(
this
Location
loc
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录