Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
6212f404
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,发现更多精彩内容 >>
提交
6212f404
编写于
1月 24, 2017
作者:
H
Heejae Chang
提交者:
GitHub
1月 24, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #16655 from heejaechang/strongname
add support for StrongNameProvider for LUT.
上级
1b907e58
50792240
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
121 addition
and
2 deletion
+121
-2
src/VisualStudio/Core/Test.Next/Services/SolutionServiceTests.cs
...ualStudio/Core/Test.Next/Services/SolutionServiceTests.cs
+56
-0
src/Workspaces/Remote/Core/Services/SolutionCreator.cs
src/Workspaces/Remote/Core/Services/SolutionCreator.cs
+65
-2
未找到文件。
src/VisualStudio/Core/Test.Next/Services/SolutionServiceTests.cs
浏览文件 @
6212f404
...
...
@@ -11,6 +11,7 @@
using
Microsoft.CodeAnalysis.Text
;
using
Microsoft.VisualStudio.LanguageServices.Remote
;
using
Roslyn.Test.Utilities
;
using
Roslyn.Utilities
;
using
Roslyn.VisualStudio.Next.UnitTests.Mocks
;
using
Xunit
;
...
...
@@ -35,6 +36,61 @@ public async Task TestCreation()
}
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
RemoteHost
)]
public
async
Task
TestStrongNameProvider
()
{
var
workspace
=
new
AdhocWorkspace
();
var
filePath
=
typeof
(
SolutionServiceTests
).
Assembly
.
Location
;
workspace
.
AddProject
(
ProjectInfo
.
Create
(
ProjectId
.
CreateNewId
(),
VersionStamp
.
Create
(),
"test"
,
"test.dll"
,
LanguageNames
.
CSharp
,
filePath
:
filePath
,
outputFilePath
:
filePath
));
var
service
=
await
GetSolutionServiceAsync
(
workspace
.
CurrentSolution
);
var
solutionChecksum
=
await
workspace
.
CurrentSolution
.
State
.
GetChecksumAsync
(
CancellationToken
.
None
);
var
solution
=
await
service
.
GetSolutionAsync
(
solutionChecksum
,
CancellationToken
.
None
);
var
compilationOptions
=
solution
.
Projects
.
First
().
CompilationOptions
;
Assert
.
True
(
compilationOptions
.
StrongNameProvider
is
DesktopStrongNameProvider
);
Assert
.
True
(
compilationOptions
.
XmlReferenceResolver
is
XmlFileResolver
);
var
dirName
=
PathUtilities
.
GetDirectoryName
(
filePath
);
var
array
=
new
[]
{
dirName
,
dirName
};
Assert
.
Equal
(
Hash
.
CombineValues
(
array
,
StringComparer
.
Ordinal
),
compilationOptions
.
StrongNameProvider
.
GetHashCode
());
Assert
.
Equal
(((
XmlFileResolver
)
compilationOptions
.
XmlReferenceResolver
).
BaseDirectory
,
dirName
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
RemoteHost
)]
public
async
Task
TestStrongNameProviderEmpty
()
{
var
workspace
=
new
AdhocWorkspace
();
var
filePath
=
"testLocation"
;
workspace
.
AddProject
(
ProjectInfo
.
Create
(
ProjectId
.
CreateNewId
(),
VersionStamp
.
Create
(),
"test"
,
"test.dll"
,
LanguageNames
.
CSharp
,
filePath
:
filePath
,
outputFilePath
:
filePath
));
var
service
=
await
GetSolutionServiceAsync
(
workspace
.
CurrentSolution
);
var
solutionChecksum
=
await
workspace
.
CurrentSolution
.
State
.
GetChecksumAsync
(
CancellationToken
.
None
);
var
solution
=
await
service
.
GetSolutionAsync
(
solutionChecksum
,
CancellationToken
.
None
);
var
compilationOptions
=
solution
.
Projects
.
First
().
CompilationOptions
;
Assert
.
True
(
compilationOptions
.
StrongNameProvider
is
DesktopStrongNameProvider
);
Assert
.
True
(
compilationOptions
.
XmlReferenceResolver
is
XmlFileResolver
);
var
array
=
new
string
[]
{
};
Assert
.
Equal
(
Hash
.
CombineValues
(
array
,
StringComparer
.
Ordinal
),
compilationOptions
.
StrongNameProvider
.
GetHashCode
());
Assert
.
Equal
(((
XmlFileResolver
)
compilationOptions
.
XmlReferenceResolver
).
BaseDirectory
,
null
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
RemoteHost
)]
public
async
Task
TestCreationWithOption
()
{
...
...
src/Workspaces/Remote/Core/Services/SolutionCreator.cs
浏览文件 @
6212f404
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Immutable
;
using
System.IO
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis.Diagnostics
;
...
...
@@ -160,7 +162,11 @@ private async Task<Solution> UpdateProjectAsync(Project project, ProjectStateChe
// changed compilation options
if
(
oldProjectChecksums
.
CompilationOptions
!=
newProjectChecksums
.
CompilationOptions
)
{
project
=
project
.
WithCompilationOptions
(
await
_assetService
.
GetAssetAsync
<
CompilationOptions
>(
newProjectChecksums
.
CompilationOptions
,
_cancellationToken
).
ConfigureAwait
(
false
));
project
=
project
.
WithCompilationOptions
(
FixUpCompilationOptions
(
project
.
State
.
ProjectInfo
.
Attributes
,
await
_assetService
.
GetAssetAsync
<
CompilationOptions
>(
newProjectChecksums
.
CompilationOptions
,
_cancellationToken
).
ConfigureAwait
(
false
)));
}
// changed parse options
...
...
@@ -424,7 +430,11 @@ private async Task<ProjectInfo> CreateProjectInfoAsync(Checksum projectChecksum)
Contract
.
ThrowIfFalse
(
_baseSolution
.
Workspace
.
Services
.
IsSupported
(
projectInfo
.
Language
));
var
compilationOptions
=
await
_assetService
.
GetAssetAsync
<
CompilationOptions
>(
projectSnapshot
.
CompilationOptions
,
_cancellationToken
).
ConfigureAwait
(
false
);
var
compilationOptions
=
FixUpCompilationOptions
(
projectInfo
,
await
_assetService
.
GetAssetAsync
<
CompilationOptions
>(
projectSnapshot
.
CompilationOptions
,
_cancellationToken
).
ConfigureAwait
(
false
));
var
parseOptions
=
await
_assetService
.
GetAssetAsync
<
ParseOptions
>(
projectSnapshot
.
ParseOptions
,
_cancellationToken
).
ConfigureAwait
(
false
);
var
p2p
=
await
CreateCollectionAsync
<
ProjectReference
>(
projectSnapshot
.
ProjectReferences
).
ConfigureAwait
(
false
);
...
...
@@ -497,5 +507,58 @@ private Project AddDocument(Project project, DocumentInfo documentInfo)
{
return
project
.
Solution
.
AddDocument
(
documentInfo
).
GetProject
(
project
.
Id
);
}
private
CompilationOptions
FixUpCompilationOptions
(
ProjectInfo
.
ProjectAttributes
info
,
CompilationOptions
compilationOptions
)
{
return
compilationOptions
.
WithXmlReferenceResolver
(
GetXmlResolver
(
info
.
FilePath
))
.
WithStrongNameProvider
(
new
DesktopStrongNameProvider
(
GetStrongNameKeyPaths
(
info
)));
}
private
static
XmlFileResolver
GetXmlResolver
(
string
filePath
)
{
// Given filePath can be any arbitary string project is created with.
// for primary solution in host such as VSWorkspace, ETA or MSBuildWorkspace
// filePath will point to actual file on disk, but in memory solultion, or
// one from AdhocWorkspace and etc, FilePath can be a random string.
// Make sure we return only if given filePath is in right form.
if
(!
PathUtilities
.
IsAbsolute
(
filePath
))
{
// xmlFileResolver can only deal with absolute path
// return Default
return
XmlFileResolver
.
Default
;
}
return
new
XmlFileResolver
(
PathUtilities
.
GetDirectoryName
(
filePath
));
}
private
ImmutableArray
<
string
>
GetStrongNameKeyPaths
(
ProjectInfo
.
ProjectAttributes
info
)
{
// Given FilePath/OutputFilePath can be any arbitary strings project is created with.
// for primary solution in host such as VSWorkspace, ETA or MSBuildWorkspace
// filePath will point to actual file on disk, but in memory solultion, or
// one from AdhocWorkspace and etc, FilePath/OutputFilePath can be a random string.
// Make sure we return only if given filePath is in right form.
if
(
info
.
FilePath
==
null
&&
info
.
OutputFilePath
==
null
)
{
// return empty since that is what IDE does for this case
// see AbstractProject.GetStrongNameKeyPaths
return
ImmutableArray
<
string
>.
Empty
;
}
var
builder
=
ArrayBuilder
<
string
>.
GetInstance
();
if
(
info
.
FilePath
!=
null
&&
PathUtilities
.
IsAbsolute
(
info
.
FilePath
))
{
// desktop strong name provider only knows how to deal with absolute path
builder
.
Add
(
PathUtilities
.
GetDirectoryName
(
info
.
FilePath
));
}
if
(
info
.
OutputFilePath
!=
null
&&
PathUtilities
.
IsAbsolute
(
info
.
OutputFilePath
))
{
// desktop strong name provider only knows how to deal with absolute path
builder
.
Add
(
PathUtilities
.
GetDirectoryName
(
info
.
OutputFilePath
));
}
return
builder
.
ToImmutableAndFree
();
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录