Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
e2fda86a
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,发现更多精彩内容 >>
提交
e2fda86a
编写于
4月 03, 2020
作者:
M
Manish Vasani
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Port UseSystemHashCode analyzer/fixer/tests to shared layer
上级
f2c14f64
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
24 addition
and
10 deletion
+24
-10
src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems
...nalyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems
+2
-0
src/Analyzers/CSharp/Tests/UseSystemHashCode/UseSystemHashCodeTests.cs
.../CSharp/Tests/UseSystemHashCode/UseSystemHashCodeTests.cs
+1
-1
src/Analyzers/CSharp/Tests/UseVarTestExtensions.cs
src/Analyzers/CSharp/Tests/UseVarTestExtensions.cs
+5
-0
src/Analyzers/Core/Analyzers/Analyzers.projitems
src/Analyzers/Core/Analyzers/Analyzers.projitems
+3
-0
src/Analyzers/Core/Analyzers/UseSystemHashCode/Analyzer.OperationDeconstructor.cs
...zers/UseSystemHashCode/Analyzer.OperationDeconstructor.cs
+0
-0
src/Analyzers/Core/Analyzers/UseSystemHashCode/Analyzer.cs
src/Analyzers/Core/Analyzers/UseSystemHashCode/Analyzer.cs
+1
-1
src/Analyzers/Core/Analyzers/UseSystemHashCode/UseSystemHashCodeDiagnosticAnalyzer.cs
.../UseSystemHashCode/UseSystemHashCodeDiagnosticAnalyzer.cs
+2
-2
src/Analyzers/Core/CodeFixes/CodeFixes.projitems
src/Analyzers/Core/CodeFixes/CodeFixes.projitems
+1
-0
src/Analyzers/Core/CodeFixes/UseSystemHashCode/UseSystemHashCodeCodeFixProvider.cs
...xes/UseSystemHashCode/UseSystemHashCodeCodeFixProvider.cs
+4
-3
src/Analyzers/VisualBasic/Tests/UseSystemHashCode/UseSystemHashCodeTests.vb
...alBasic/Tests/UseSystemHashCode/UseSystemHashCodeTests.vb
+0
-0
src/Analyzers/VisualBasic/Tests/VisualBasicAnalyzers.UnitTests.projitems
...isualBasic/Tests/VisualBasicAnalyzers.UnitTests.projitems
+1
-0
src/Features/Core/Portable/GenerateEqualsAndGetHashCodeFromMembers/AbstractGenerateEqualsAndGetHashCodeService.cs
...romMembers/AbstractGenerateEqualsAndGetHashCodeService.cs
+4
-3
未找到文件。
src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems
浏览文件 @
e2fda86a
...
...
@@ -70,8 +70,10 @@
<Compile
Include=
"$(MSBuildThisFileDirectory)UsePatternMatching\CSharpAsAndNullCheckTests_FixAllTests.cs"
/>
<Compile
Include=
"$(MSBuildThisFileDirectory)UsePatternMatching\CSharpIsAndCastCheckDiagnosticAnalyzerTests.cs"
/>
<Compile
Include=
"$(MSBuildThisFileDirectory)UsePatternMatching\CSharpIsAndCastCheckDiagnosticAnalyzerTests_FixAllTests.cs"
/>
<Compile
Include=
"$(MSBuildThisFileDirectory)UseSystemHashCode\UseSystemHashCodeTests.cs"
/>
<Compile
Include=
"$(MSBuildThisFileDirectory)UseThrowExpression\UseThrowExpressionTests.cs"
/>
<Compile
Include=
"$(MSBuildThisFileDirectory)UseThrowExpression\UseThrowExpressionTests_FixAllTests.cs"
/>
<Compile
Include=
"$(MSBuildThisFileDirectory)UseVarTestExtensions.cs"
/>
<Compile
Include=
"$(MSBuildThisFileDirectory)ValidateFormatString\ValidateFormatStringTests.cs"
/>
</ItemGroup>
<ItemGroup
Condition=
"'$(DefaultLanguageSourceExtension)' != '' AND '$(BuildingInsideVisualStudio)' != 'true'"
>
...
...
src/
EditorFeatures/CSharpTest
/UseSystemHashCode/UseSystemHashCodeTests.cs
→
src/
Analyzers/CSharp/Tests
/UseSystemHashCode/UseSystemHashCodeTests.cs
浏览文件 @
e2fda86a
...
...
@@ -1209,7 +1209,7 @@ public override int GetHashCode()
hash.Add(i);
return hash.ToHashCode();
}
}"
,
options
:
this
.
PreferImplicitTypeWithInfo
(
));
}"
,
options
:
UseVarTestExtensions
.
PreferImplicitTypeWithInfo
(
this
));
}
[
WorkItem
(
39916
,
"https://github.com/dotnet/roslyn/issues/39916"
)]
...
...
src/
EditorFeatures/CSharpTest/CodeAction
s/UseVarTestExtensions.cs
→
src/
Analyzers/CSharp/Test
s/UseVarTestExtensions.cs
浏览文件 @
e2fda86a
...
...
@@ -5,7 +5,12 @@
using
Microsoft.CodeAnalysis.CodeStyle
;
using
Microsoft.CodeAnalysis.CSharp.CodeStyle
;
using
Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions
;
#if CODE_STYLE
using
AbstractCodeActionOrUserDiagnosticTest
=
Microsoft
.
CodeAnalysis
.
Editor
.
CSharp
.
UnitTests
.
Diagnostics
.
AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest
;
#else
using
static
Microsoft
.
CodeAnalysis
.
Editor
.
UnitTests
.
CodeActions
.
AbstractCodeActionOrUserDiagnosticTest
;
#endif
namespace
Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.CodeActions
{
...
...
src/Analyzers/Core/Analyzers/Analyzers.projitems
浏览文件 @
e2fda86a
...
...
@@ -67,6 +67,9 @@
<Compile
Include=
"$(MSBuildThisFileDirectory)UseNullPropagation\AbstractUseNullPropagationDiagnosticAnalyzer.cs"
/>
<Compile
Include=
"$(MSBuildThisFileDirectory)UseObjectInitializer\AbstractUseObjectInitializerDiagnosticAnalyzer.cs"
/>
<Compile
Include=
"$(MSBuildThisFileDirectory)UseObjectInitializer\ObjectCreationExpressionAnalyzer.cs"
/>
<Compile
Include=
"$(MSBuildThisFileDirectory)UseSystemHashCode\Analyzer.cs"
/>
<Compile
Include=
"$(MSBuildThisFileDirectory)UseSystemHashCode\Analyzer.OperationDeconstructor.cs"
/>
<Compile
Include=
"$(MSBuildThisFileDirectory)UseSystemHashCode\UseSystemHashCodeDiagnosticAnalyzer.cs"
/>
<Compile
Include=
"$(MSBuildThisFileDirectory)UseThrowExpression\AbstractUseThrowExpressionDiagnosticAnalyzer.cs"
/>
<Compile
Include=
"$(MSBuildThisFileDirectory)ValidateFormatString\AbstractValidateFormatStringDiagnosticAnalyzer.cs"
/>
<Compile
Include=
"$(MSBuildThisFileDirectory)ValidateFormatString\ValidateFormatStringOption.cs"
/>
...
...
src/
Features/Core/Portable
/UseSystemHashCode/Analyzer.OperationDeconstructor.cs
→
src/
Analyzers/Core/Analyzers
/UseSystemHashCode/Analyzer.OperationDeconstructor.cs
浏览文件 @
e2fda86a
文件已移动
src/
Features/Core/Portable
/UseSystemHashCode/Analyzer.cs
→
src/
Analyzers/Core/Analyzers
/UseSystemHashCode/Analyzer.cs
浏览文件 @
e2fda86a
...
...
@@ -14,7 +14,7 @@
namespace
Microsoft.CodeAnalysis.UseSystemHashCode
{
/// <summary>
/// Helper code to support both
<see cref="UseSystemHashCodeCodeFixProvider"/>
and
/// Helper code to support both
"UseSystemHashCodeCodeFixProvider"
and
/// <see cref="UseSystemHashCodeDiagnosticAnalyzer"/>.
/// </summary>
internal
partial
struct
Analyzer
...
...
src/
Features/Core/Portable
/UseSystemHashCode/UseSystemHashCodeDiagnosticAnalyzer.cs
→
src/
Analyzers/Core/Analyzers
/UseSystemHashCode/UseSystemHashCodeDiagnosticAnalyzer.cs
浏览文件 @
e2fda86a
...
...
@@ -16,8 +16,8 @@ internal class UseSystemHashCodeDiagnosticAnalyzer : AbstractBuiltInCodeStyleDia
public
UseSystemHashCodeDiagnosticAnalyzer
()
:
base
(
IDEDiagnosticIds
.
UseSystemHashCode
,
CodeStyleOptions2
.
PreferSystemHashCode
,
new
LocalizableResourceString
(
nameof
(
FeaturesResources
.
Use_System_HashCode
),
FeaturesResources
.
ResourceManager
,
typeof
(
Feature
sResources
)),
new
LocalizableResourceString
(
nameof
(
FeaturesResources
.
GetHashCode_implementation_can_be_simplified
),
FeaturesResources
.
ResourceManager
,
typeof
(
Feature
sResources
)))
new
LocalizableResourceString
(
nameof
(
AnalyzersResources
.
Use_System_HashCode
),
AnalyzersResources
.
ResourceManager
,
typeof
(
Analyzer
sResources
)),
new
LocalizableResourceString
(
nameof
(
AnalyzersResources
.
GetHashCode_implementation_can_be_simplified
),
AnalyzersResources
.
ResourceManager
,
typeof
(
Analyzer
sResources
)))
{
}
...
...
src/Analyzers/Core/CodeFixes/CodeFixes.projitems
浏览文件 @
e2fda86a
...
...
@@ -41,6 +41,7 @@
<Compile
Include=
"$(MSBuildThisFileDirectory)UseExplicitTupleName\UseExplicitTupleNameCodeFixProvider.cs"
/>
<Compile
Include=
"$(MSBuildThisFileDirectory)UseNullPropagation\AbstractUseNullPropagationCodeFixProvider.cs"
/>
<Compile
Include=
"$(MSBuildThisFileDirectory)UseObjectInitializer\AbstractUseObjectInitializerCodeFixProvider.cs"
/>
<Compile
Include=
"$(MSBuildThisFileDirectory)UseSystemHashCode\UseSystemHashCodeCodeFixProvider.cs"
/>
<Compile
Include=
"$(MSBuildThisFileDirectory)UseThrowExpression\UseThrowExpressionCodeFixProvider.cs"
/>
</ItemGroup>
<ItemGroup
Condition=
"'$(DefaultLanguageSourceExtension)' != '' AND '$(BuildingInsideVisualStudio)' != 'true'"
>
...
...
src/
Features/Core/Portable
/UseSystemHashCode/UseSystemHashCodeCodeFixProvider.cs
→
src/
Analyzers/Core/CodeFixes
/UseSystemHashCode/UseSystemHashCodeCodeFixProvider.cs
浏览文件 @
e2fda86a
...
...
@@ -51,6 +51,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
SyntaxEditor
editor
,
CancellationToken
cancellationToken
)
{
var
generator
=
SyntaxGenerator
.
GetGenerator
(
document
);
var
generatorInternal
=
document
.
GetRequiredLanguageService
<
SyntaxGeneratorInternal
>();
var
declarationService
=
document
.
GetLanguageService
<
ISymbolDeclarationService
>();
if
(
declarationService
==
null
)
{
...
...
@@ -88,16 +89,16 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
var
updatedDecl
=
generator
.
WithStatements
(
methodBlock
,
generator
.
CreateGetHashCodeStatementsUsingSystemHashCode
(
analyzer
.
SystemHashCodeType
,
components
));
generatorInternal
,
analyzer
.
SystemHashCodeType
,
components
));
editor
.
ReplaceNode
(
methodBlock
,
updatedDecl
);
}
}
}
private
class
MyCodeAction
:
C
odeAction
.
DocumentChangeAction
private
class
MyCodeAction
:
C
ustomCodeActions
.
DocumentChangeAction
{
public
MyCodeAction
(
Func
<
CancellationToken
,
Task
<
Document
>>
createChangedDocument
)
:
base
(
FeaturesResources
.
Use_System_HashCode
,
createChangedDocument
,
Feature
sResources
.
Use_System_HashCode
)
:
base
(
AnalyzersResources
.
Use_System_HashCode
,
createChangedDocument
,
Analyzer
sResources
.
Use_System_HashCode
)
{
}
}
...
...
src/
EditorFeatures/VisualBasicTest
/UseSystemHashCode/UseSystemHashCodeTests.vb
→
src/
Analyzers/VisualBasic/Tests
/UseSystemHashCode/UseSystemHashCodeTests.vb
浏览文件 @
e2fda86a
文件已移动
src/Analyzers/VisualBasic/Tests/VisualBasicAnalyzers.UnitTests.projitems
浏览文件 @
e2fda86a
...
...
@@ -40,6 +40,7 @@
<Compile
Include=
"$(MSBuildThisFileDirectory)UseExplicitTupleName\UseExplicitTupleNameTests.vb"
/>
<Compile
Include=
"$(MSBuildThisFileDirectory)UseNullPropagation\UseNullPropagationTests.vb"
/>
<Compile
Include=
"$(MSBuildThisFileDirectory)UseObjectInitializer\UseObjectInitializerTests.vb"
/>
<Compile
Include=
"$(MSBuildThisFileDirectory)UseSystemHashCode\UseSystemHashCodeTests.vb"
/>
<Compile
Include=
"$(MSBuildThisFileDirectory)ValidateFormatString\ValidateFormatStringTests.vb"
/>
</ItemGroup>
<ItemGroup
Condition=
"'$(DefaultLanguageSourceExtension)' != '' AND '$(BuildingInsideVisualStudio)' != 'true'"
>
...
...
src/Features/Core/Portable/GenerateEqualsAndGetHashCodeFromMembers/AbstractGenerateEqualsAndGetHashCodeService.cs
浏览文件 @
e2fda86a
...
...
@@ -155,12 +155,13 @@ public async Task<Document> FormatDocumentAsync(Document document, CancellationT
if
(
components
.
Length
>
0
&&
hashCodeType
!=
null
)
{
return
factory
.
CreateGetHashCodeStatementsUsingSystemHashCode
(
hashCodeType
,
components
);
return
factory
.
CreateGetHashCodeStatementsUsingSystemHashCode
(
factory
.
SyntaxGeneratorInternal
,
hashCodeType
,
components
);
}
// Otherwise, try to just spit out a reasonable hash code for these members.
var
statements
=
factory
.
CreateGetHashCodeMethodStatements
(
compilation
,
namedType
,
members
,
useInt64
:
false
);
factory
.
SyntaxGeneratorInternal
,
compilation
,
namedType
,
members
,
useInt64
:
false
);
// Unfortunately, our 'reasonable' hash code may overflow in checked contexts.
// C# can handle this by adding 'checked{}' around the code, VB has to jump
...
...
@@ -194,7 +195,7 @@ public async Task<Document> FormatDocumentAsync(Document document, CancellationT
//
// This does mean all hashcodes will be positive. But it will avoid the overflow problem.
return
factory
.
CreateGetHashCodeMethodStatements
(
compilation
,
namedType
,
members
,
useInt64
:
true
);
factory
.
SyntaxGeneratorInternal
,
compilation
,
namedType
,
members
,
useInt64
:
true
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录