Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
0984fad3
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,发现更多精彩内容 >>
提交
0984fad3
编写于
12月 07, 2016
作者:
H
Heejae Chang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix analyzer reference round trip issue with shadow copy assembly loader
上级
9b52a613
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
104 addition
and
48 deletion
+104
-48
src/VisualStudio/Core/Test.Next/Services/ServiceHubServicesTests.cs
...Studio/Core/Test.Next/Services/ServiceHubServicesTests.cs
+2
-2
src/Workspaces/Core/Portable/Execution/AbstractReferenceSerializationService.cs
...rtable/Execution/AbstractReferenceSerializationService.cs
+55
-46
src/Workspaces/CoreTest/Execution/SnapshotSerializationTests.cs
...rkspaces/CoreTest/Execution/SnapshotSerializationTests.cs
+44
-0
src/Workspaces/Remote/Core/Services/SolutionCreator.cs
src/Workspaces/Remote/Core/Services/SolutionCreator.cs
+3
-0
未找到文件。
src/VisualStudio/Core/Test.Next/Services/ServiceHubServicesTests.cs
浏览文件 @
0984fad3
...
...
@@ -178,10 +178,10 @@ private static Solution UpdateSolution(Solution solution, string projectName, st
{
var
(
project
,
document
)
=
GetProjectAndDocument
(
solution
,
projectName
,
documentName
);
return
document
.
WithText
(
GetN
ame
Text
(
document
,
csAddition
,
vbAddition
)).
Project
.
Solution
;
return
document
.
WithText
(
GetN
ew
Text
(
document
,
csAddition
,
vbAddition
)).
Project
.
Solution
;
}
private
static
SourceText
GetN
ame
Text
(
Document
document
,
string
csAddition
,
string
vbAddition
)
private
static
SourceText
GetN
ew
Text
(
Document
document
,
string
csAddition
,
string
vbAddition
)
{
if
(
document
.
Project
.
Language
==
LanguageNames
.
CSharp
)
{
...
...
src/Workspaces/Core/Portable/Execution/AbstractReferenceSerializationService.cs
浏览文件 @
0984fad3
...
...
@@ -85,7 +85,7 @@ public Checksum CreateChecksum(AnalyzerReference reference, CancellationToken ca
using
(
var
stream
=
SerializableBytes
.
CreateWritableStream
())
using
(
var
writer
=
new
StreamObjectWriter
(
stream
,
cancellationToken
:
cancellationToken
))
{
WriteTo
(
reference
,
writer
,
cancellationToken
);
WriteTo
(
reference
,
writer
,
c
hecksum
:
true
,
cancellationToken
:
c
ancellationToken
);
stream
.
Position
=
0
;
return
Checksum
.
Create
(
stream
);
...
...
@@ -126,50 +126,7 @@ public MetadataReference ReadMetadataReferenceFrom(ObjectReader reader, Cancella
public
void
WriteTo
(
AnalyzerReference
reference
,
ObjectWriter
writer
,
CancellationToken
cancellationToken
)
{
cancellationToken
.
ThrowIfCancellationRequested
();
var
file
=
reference
as
AnalyzerFileReference
;
if
(
file
!=
null
)
{
// fail to load analyzer assembly
var
assemblyPath
=
TryGetAnalyzerAssemblyPath
(
file
);
if
(
assemblyPath
==
null
)
{
WriteUnresolvedAnalyzerReferenceTo
(
reference
,
writer
);
return
;
}
writer
.
WriteString
(
nameof
(
AnalyzerFileReference
));
writer
.
WriteInt32
((
int
)
SerializationKinds
.
FilePath
);
writer
.
WriteString
(
file
.
FullPath
);
// TODO: remove this kind of host specific knowledge from common layer.
// but think moving it to host layer where this implementation detail actually exist.
//
// analyzer assembly path to load analyzer acts like
// snapshot version for analyzer (since it is based on shadow copy)
// we can't send over bits and load analyer from memory (image) due to CLR not being able
// to find satellite dlls for analyzers.
writer
.
WriteString
(
assemblyPath
);
return
;
}
var
unresolved
=
reference
as
UnresolvedAnalyzerReference
;
if
(
unresolved
!=
null
)
{
WriteUnresolvedAnalyzerReferenceTo
(
reference
,
writer
);
return
;
}
var
image
=
reference
as
AnalyzerImageReference
;
if
(
image
!=
null
)
{
// TODO: think a way to support this or a way to deal with this kind of situation.
throw
new
NotSupportedException
(
nameof
(
AnalyzerImageReference
));
}
throw
ExceptionUtilities
.
UnexpectedValue
(
reference
.
GetType
());
WriteTo
(
reference
,
writer
,
checksum
:
false
,
cancellationToken
:
cancellationToken
);
}
public
AnalyzerReference
ReadAnalyzerReferenceFrom
(
ObjectReader
reader
,
CancellationToken
cancellationToken
)
...
...
@@ -300,7 +257,7 @@ private PortableExecutableReference ReadPortableExecutableReferenceFrom(ObjectRe
// TODO: deal with xml document provider properly
// should we shadow copy xml doc comment?
return
new
SerializedMetadataReference
(
properties
,
filePath
,
tuple
.
Value
.
metadata
,
tuple
.
Value
.
storages
,
properties
,
filePath
,
tuple
.
Value
.
metadata
,
tuple
.
Value
.
storages
,
XmlDocumentationProvider
.
Default
);
}
...
...
@@ -543,6 +500,58 @@ private unsafe void WriteTo(MetadataReader reader, ObjectWriter writer, Cancella
writer
.
WriteValue
(
bytes
);
}
private
void
WriteTo
(
AnalyzerReference
reference
,
ObjectWriter
writer
,
bool
checksum
,
CancellationToken
cancellationToken
)
{
cancellationToken
.
ThrowIfCancellationRequested
();
var
file
=
reference
as
AnalyzerFileReference
;
if
(
file
!=
null
)
{
// fail to load analyzer assembly
var
assemblyPath
=
TryGetAnalyzerAssemblyPath
(
file
);
if
(
assemblyPath
==
null
)
{
WriteUnresolvedAnalyzerReferenceTo
(
reference
,
writer
);
return
;
}
writer
.
WriteString
(
nameof
(
AnalyzerFileReference
));
writer
.
WriteInt32
((
int
)
SerializationKinds
.
FilePath
);
if
(!
checksum
)
{
// we don't write full path when creating checksum
writer
.
WriteString
(
file
.
FullPath
);
}
// TODO: remove this kind of host specific knowledge from common layer.
// but think moving it to host layer where this implementation detail actually exist.
//
// analyzer assembly path to load analyzer acts like
// snapshot version for analyzer (since it is based on shadow copy)
// we can't send over bits and load analyer from memory (image) due to CLR not being able
// to find satellite dlls for analyzers.
writer
.
WriteString
(
assemblyPath
);
return
;
}
var
unresolved
=
reference
as
UnresolvedAnalyzerReference
;
if
(
unresolved
!=
null
)
{
WriteUnresolvedAnalyzerReferenceTo
(
reference
,
writer
);
return
;
}
var
image
=
reference
as
AnalyzerImageReference
;
if
(
image
!=
null
)
{
// TODO: think a way to support this or a way to deal with this kind of situation.
throw
new
NotSupportedException
(
nameof
(
AnalyzerImageReference
));
}
throw
ExceptionUtilities
.
UnexpectedValue
(
reference
.
GetType
());
}
private
static
void
WriteUnresolvedAnalyzerReferenceTo
(
AnalyzerReference
reference
,
ObjectWriter
writer
)
{
writer
.
WriteString
(
nameof
(
UnresolvedAnalyzerReference
));
...
...
src/Workspaces/CoreTest/Execution/SnapshotSerializationTests.cs
浏览文件 @
0984fad3
...
...
@@ -388,6 +388,37 @@ public async Task Missing_Analyzer_Serailization_Desktop_Test()
var
assetFromStorage2
=
await
CloneAssetAsync
(
serializer
,
assetFromStorage
).
ConfigureAwait
(
false
);
}
[
Fact
]
public
async
Task
RoundTrip_Analyzer_Serailization_Test
()
{
var
workspace
=
new
AdhocWorkspace
();
var
serializer
=
new
Serializer
(
workspace
);
var
reference
=
new
AnalyzerFileReference
(
typeof
(
object
).
Assembly
.
Location
,
new
MockShadowCopyAnalyzerAssemblyLoader
());
// make sure this doesn't throw
var
assetFromFile
=
SolutionAsset
.
Create
(
serializer
.
CreateChecksum
(
reference
,
CancellationToken
.
None
),
reference
,
serializer
);
var
assetFromStorage
=
await
CloneAssetAsync
(
serializer
,
assetFromFile
).
ConfigureAwait
(
false
);
var
assetFromStorage2
=
await
CloneAssetAsync
(
serializer
,
assetFromStorage
).
ConfigureAwait
(
false
);
}
[
Fact
]
public
async
Task
RoundTrip_Analyzer_Serailization_Desktop_Test
()
{
var
hostServices
=
MefHostServices
.
Create
(
MefHostServices
.
DefaultAssemblies
.
Add
(
typeof
(
Host
.
TemporaryStorageServiceFactory
.
TemporaryStorageService
).
Assembly
));
var
workspace
=
new
AdhocWorkspace
(
hostServices
);
var
serializer
=
new
Serializer
(
workspace
);
var
reference
=
new
AnalyzerFileReference
(
typeof
(
object
).
Assembly
.
Location
,
new
MockShadowCopyAnalyzerAssemblyLoader
());
// make sure this doesn't throw
var
assetFromFile
=
SolutionAsset
.
Create
(
serializer
.
CreateChecksum
(
reference
,
CancellationToken
.
None
),
reference
,
serializer
);
var
assetFromStorage
=
await
CloneAssetAsync
(
serializer
,
assetFromFile
).
ConfigureAwait
(
false
);
var
assetFromStorage2
=
await
CloneAssetAsync
(
serializer
,
assetFromStorage
).
ConfigureAwait
(
false
);
}
[
Fact
]
public
async
Task
SnapshotWithMissingReferencesTest
()
{
...
...
@@ -624,5 +655,18 @@ protected override PortableExecutableReference WithPropertiesImpl(MetadataRefere
return
this
;
}
}
private
class
MockShadowCopyAnalyzerAssemblyLoader
:
IAnalyzerAssemblyLoader
{
public
void
AddDependencyLocation
(
string
fullPath
)
{
}
public
Assembly
LoadFromPath
(
string
fullPath
)
{
// return something other than given one. mimicing behavior of shadow copy
return
typeof
(
SharedAttribute
).
Assembly
;
}
}
}
}
\ No newline at end of file
src/Workspaces/Remote/Core/Services/SolutionCreator.cs
浏览文件 @
0984fad3
...
...
@@ -74,6 +74,9 @@ public async Task<Solution> CreateSolutionAsync(Checksum newSolutionChecksum)
solution
=
await
UpdateProjectsAsync
(
solution
,
oldSolutionChecksums
.
Projects
,
newSolutionChecksums
.
Projects
).
ConfigureAwait
(
false
);
}
// make sure created solution has same checksum as given one
Contract
.
ThrowIfFalse
(
newSolutionChecksum
==
await
solution
.
State
.
GetChecksumAsync
(
_cancellationToken
).
ConfigureAwait
(
false
));
return
solution
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录