Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
146f9208
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,发现更多精彩内容 >>
未验证
提交
146f9208
编写于
4月 24, 2020
作者:
T
Tomáš Matoušek
提交者:
GitHub
4月 24, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Temporarily allow duplicate analyzer references (#43567)
上级
52a56c4d
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
46 addition
and
7 deletion
+46
-7
src/Workspaces/Core/Portable/Workspace/Solution/ProjectInfo.cs
...orkspaces/Core/Portable/Workspace/Solution/ProjectInfo.cs
+2
-2
src/Workspaces/Core/Portable/Workspace/Solution/Solution.cs
src/Workspaces/Core/Portable/Workspace/Solution/Solution.cs
+1
-1
src/Workspaces/CoreTest/Execution/SnapshotSerializationTests.cs
...rkspaces/CoreTest/Execution/SnapshotSerializationTests.cs
+40
-0
src/Workspaces/CoreTest/SolutionTests/ProjectInfoTests.cs
src/Workspaces/CoreTest/SolutionTests/ProjectInfoTests.cs
+2
-3
src/Workspaces/CoreTest/SolutionTests/SolutionTests.cs
src/Workspaces/CoreTest/SolutionTests/SolutionTests.cs
+1
-1
未找到文件。
src/Workspaces/Core/Portable/Workspace/Solution/ProjectInfo.cs
浏览文件 @
146f9208
...
...
@@ -231,7 +231,7 @@ public sealed class ProjectInfo
PublicContract
.
ToBoxedImmutableArrayWithDistinctNonNullItems
(
documents
,
nameof
(
documents
)),
PublicContract
.
ToBoxedImmutableArrayWithDistinctNonNullItems
(
projectReferences
,
nameof
(
projectReferences
)),
PublicContract
.
ToBoxedImmutableArrayWithDistinctNonNullItems
(
metadataReferences
,
nameof
(
metadataReferences
)),
PublicContract
.
ToBoxedImmutableArrayWith
Distinct
NonNullItems
(
analyzerReferences
,
nameof
(
analyzerReferences
)),
PublicContract
.
ToBoxedImmutableArrayWithNonNullItems
(
analyzerReferences
,
nameof
(
analyzerReferences
)),
PublicContract
.
ToBoxedImmutableArrayWithDistinctNonNullItems
(
additionalDocuments
,
nameof
(
additionalDocuments
)),
analyzerConfigDocuments
:
SpecializedCollections
.
EmptyBoxedImmutableArray
<
DocumentInfo
>(),
hostObjectType
);
...
...
@@ -336,7 +336,7 @@ public ProjectInfo WithMetadataReferences(IEnumerable<MetadataReference>? metada
=>
With
(
metadataReferences
:
PublicContract
.
ToBoxedImmutableArrayWithDistinctNonNullItems
(
metadataReferences
,
nameof
(
metadataReferences
)));
public
ProjectInfo
WithAnalyzerReferences
(
IEnumerable
<
AnalyzerReference
>?
analyzerReferences
)
=>
With
(
analyzerReferences
:
PublicContract
.
ToBoxedImmutableArrayWith
Distinct
NonNullItems
(
analyzerReferences
,
nameof
(
analyzerReferences
)));
=>
With
(
analyzerReferences
:
PublicContract
.
ToBoxedImmutableArrayWithNonNullItems
(
analyzerReferences
,
nameof
(
analyzerReferences
)));
internal
string
GetDebuggerDisplay
()
=>
nameof
(
ProjectInfo
)
+
" "
+
Name
+
(!
string
.
IsNullOrWhiteSpace
(
FilePath
)
?
" "
+
FilePath
:
""
);
...
...
src/Workspaces/Core/Portable/Workspace/Solution/Solution.cs
浏览文件 @
146f9208
...
...
@@ -802,7 +802,7 @@ public Solution WithProjectAnalyzerReferences(ProjectId projectId, IEnumerable<A
var
newState
=
_state
.
WithProjectAnalyzerReferences
(
projectId
,
PublicContract
.
ToBoxedImmutableArrayWith
Distinct
NonNullItems
(
analyzerReferences
,
nameof
(
analyzerReferences
)));
PublicContract
.
ToBoxedImmutableArrayWithNonNullItems
(
analyzerReferences
,
nameof
(
analyzerReferences
)));
if
(
newState
==
_state
)
{
...
...
src/Workspaces/CoreTest/Execution/SnapshotSerializationTests.cs
浏览文件 @
146f9208
...
...
@@ -21,6 +21,7 @@
using
Microsoft.CodeAnalysis.Test.Utilities
;
using
Microsoft.CodeAnalysis.Text
;
using
Microsoft.CodeAnalysis.UnitTests.Execution
;
using
Roslyn.Test.Utilities
;
using
Roslyn.Utilities
;
using
Xunit
;
...
...
@@ -501,6 +502,45 @@ public async Task SnapshotWithMissingReferencesTest()
var
recovered
=
await
GetSolutionAsync
(
snapshotService
,
snapshot
).
ConfigureAwait
(
false
);
}
[
Fact
]
public
async
Task
SnapshotWithIdenticalAnalyzerFiles
()
{
var
hostServices
=
MefHostServices
.
Create
(
MefHostServices
.
DefaultAssemblies
.
Add
(
typeof
(
Host
.
TemporaryStorageServiceFactory
.
TemporaryStorageService
).
Assembly
));
var
project
=
new
AdhocWorkspace
(
hostServices
).
CurrentSolution
.
AddProject
(
"Project"
,
"Project.dll"
,
LanguageNames
.
CSharp
);
using
var
temp
=
new
TempRoot
();
var
dir
=
temp
.
CreateDirectory
();
// create two analyzer assembly files whose content is identical but path is different:
var
file1
=
dir
.
CreateFile
(
"analyzer1.dll"
).
WriteAllBytes
(
TestResources
.
AnalyzerTests
.
FaultyAnalyzer
);
var
file2
=
dir
.
CreateFile
(
"analyzer2.dll"
).
WriteAllBytes
(
TestResources
.
AnalyzerTests
.
FaultyAnalyzer
);
var
analyzer1
=
new
AnalyzerFileReference
(
file1
.
Path
,
DummyAssemblyLoader
.
Instance
);
var
analyzer2
=
new
AnalyzerFileReference
(
file2
.
Path
,
DummyAssemblyLoader
.
Instance
);
project
=
project
.
AddAnalyzerReferences
(
new
[]
{
analyzer1
,
analyzer2
});
var
snapshotService
=
(
IRemotableDataService
)
new
RemotableDataServiceFactory
().
CreateService
(
project
.
Solution
.
Workspace
.
Services
);
using
var
snapshot
=
await
snapshotService
.
CreatePinnedRemotableDataScopeAsync
(
project
.
Solution
,
CancellationToken
.
None
).
ConfigureAwait
(
false
);
var
recovered
=
await
GetSolutionAsync
(
snapshotService
,
snapshot
).
ConfigureAwait
(
false
);
AssertEx
.
Equal
(
new
[]
{
file1
.
Path
,
file1
.
Path
},
recovered
.
GetProject
(
project
.
Id
).
AnalyzerReferences
.
Select
(
r
=>
r
.
FullPath
));
}
internal
class
DummyAssemblyLoader
:
IAnalyzerAssemblyLoader
{
public
static
DummyAssemblyLoader
Instance
=
new
DummyAssemblyLoader
();
public
void
AddDependencyLocation
(
string
fullPath
)
{
}
public
Assembly
LoadFromPath
(
string
fullPath
)
=>
Assembly
.
LoadFrom
(
fullPath
);
}
[
Fact
]
public
async
Task
UnknownLanguageTest
()
{
...
...
src/Workspaces/CoreTest/SolutionTests/ProjectInfoTests.cs
浏览文件 @
146f9208
...
...
@@ -53,8 +53,7 @@ public void Create_Errors_DuplicateItems()
analyzerReferences
:
new
AnalyzerReference
[]
{
null
}));
var
analyzerReference
=
new
TestAnalyzerReference
();
Assert
.
Throws
<
ArgumentException
>(
"analyzerReferences[1]"
,
()
=>
ProjectInfo
.
Create
(
pid
,
VersionStamp
.
Default
,
"proj"
,
"assembly"
,
"C#"
,
analyzerReferences
:
new
[]
{
analyzerReference
,
analyzerReference
}));
ProjectInfo
.
Create
(
pid
,
VersionStamp
.
Default
,
"proj"
,
"assembly"
,
"C#"
,
analyzerReferences
:
new
[]
{
analyzerReference
,
analyzerReference
});
Assert
.
Throws
<
ArgumentNullException
>(()
=>
ProjectInfo
.
Create
(
pid
,
VersionStamp
.
Default
,
name
:
"Goo"
,
assemblyName
:
"Bar"
,
language
:
"C#"
,
metadataReferences
:
new
MetadataReference
[]
{
null
}));
...
...
@@ -193,7 +192,7 @@ public void TestProperties()
SolutionTestHelpers
.
TestListProperty
(
instance
,
(
old
,
value
)
=>
old
.
WithDocuments
(
value
),
opt
=>
opt
.
Documents
,
documentInfo
,
allowDuplicates
:
false
);
SolutionTestHelpers
.
TestListProperty
(
instance
,
(
old
,
value
)
=>
old
.
WithAdditionalDocuments
(
value
),
opt
=>
opt
.
AdditionalDocuments
,
documentInfo
,
allowDuplicates
:
false
);
SolutionTestHelpers
.
TestListProperty
(
instance
,
(
old
,
value
)
=>
old
.
WithAnalyzerConfigDocuments
(
value
),
opt
=>
opt
.
AnalyzerConfigDocuments
,
documentInfo
,
allowDuplicates
:
false
);
SolutionTestHelpers
.
TestListProperty
(
instance
,
(
old
,
value
)
=>
old
.
WithAnalyzerReferences
(
value
),
opt
=>
opt
.
AnalyzerReferences
,
(
AnalyzerReference
)
new
TestAnalyzerReference
(),
allowDuplicates
:
fals
e
);
SolutionTestHelpers
.
TestListProperty
(
instance
,
(
old
,
value
)
=>
old
.
WithAnalyzerReferences
(
value
),
opt
=>
opt
.
AnalyzerReferences
,
(
AnalyzerReference
)
new
TestAnalyzerReference
(),
allowDuplicates
:
tru
e
);
SolutionTestHelpers
.
TestListProperty
(
instance
,
(
old
,
value
)
=>
old
.
WithMetadataReferences
(
value
),
opt
=>
opt
.
MetadataReferences
,
(
MetadataReference
)
new
TestMetadataReference
(),
allowDuplicates
:
false
);
SolutionTestHelpers
.
TestListProperty
(
instance
,
(
old
,
value
)
=>
old
.
WithProjectReferences
(
value
),
opt
=>
opt
.
ProjectReferences
,
new
ProjectReference
(
projectId
),
allowDuplicates
:
false
);
}
...
...
src/Workspaces/CoreTest/SolutionTests/SolutionTests.cs
浏览文件 @
146f9208
...
...
@@ -897,7 +897,7 @@ public void WithProjectAnalyzerReferences()
(
old
,
value
)
=>
old
.
WithProjectAnalyzerReferences
(
projectId
,
value
),
opt
=>
opt
.
GetProject
(
projectId
)!.
AnalyzerReferences
,
analyzerRef
,
allowDuplicates
:
fals
e
);
allowDuplicates
:
tru
e
);
Assert
.
Throws
<
ArgumentNullException
>(
"projectId"
,
()
=>
solution
.
WithProjectAnalyzerReferences
(
null
!,
new
[]
{
analyzerRef
}));
Assert
.
Throws
<
InvalidOperationException
>(()
=>
solution
.
WithProjectAnalyzerReferences
(
ProjectId
.
CreateNewId
(),
new
[]
{
analyzerRef
}));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录