Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
dafc24c2
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,发现更多精彩内容 >>
提交
dafc24c2
编写于
5月 28, 2015
作者:
M
Matt Warren
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add shared metadata tests for msbuild workspace
上级
6f7d7e63
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
147 addition
and
0 deletion
+147
-0
src/Workspaces/CoreTest/ServicesTest.csproj
src/Workspaces/CoreTest/ServicesTest.csproj
+3
-0
src/Workspaces/CoreTest/TestFiles/CSharpProject_CSharpProject_ExternAlias2.csproj
...TestFiles/CSharpProject_CSharpProject_ExternAlias2.csproj
+51
-0
src/Workspaces/CoreTest/WorkspaceTests/MSBuildWorkspaceTests.cs
...rkspaces/CoreTest/WorkspaceTests/MSBuildWorkspaceTests.cs
+93
-0
未找到文件。
src/Workspaces/CoreTest/ServicesTest.csproj
浏览文件 @
dafc24c2
...
...
@@ -298,6 +298,9 @@
<SubType>
Designer
</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<EmbeddedResource
Include=
"TestFiles\CSharpProject_CSharpProject_ExternAlias2.csproj"
/>
</ItemGroup>
<ImportGroup
Label=
"Targets"
>
<Import
Project=
"..\..\Tools\Microsoft.CodeAnalysis.Toolset.Open\Targets\VSL.Imports.targets"
/>
<Import
Project=
"..\..\..\build\VSL.Imports.Closed.targets"
/>
...
...
src/Workspaces/CoreTest/TestFiles/CSharpProject_CSharpProject_ExternAlias2.csproj
0 → 100644
浏览文件 @
dafc24c2
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -->
<Project
ToolsVersion=
"4.0"
DefaultTargets=
"Build"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<Import
Project=
"$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"
Condition=
"Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"
/>
<PropertyGroup>
<Configuration
Condition=
" '$(Configuration)' == '' "
>
Debug
</Configuration>
<Platform
Condition=
" '$(Platform)' == '' "
>
AnyCPU
</Platform>
<ProjectGuid>
{74404B73-C865-49CF-A586-C34759F2C95B}
</ProjectGuid>
<OutputType>
WinExe
</OutputType>
<AppDesignerFolder>
Properties
</AppDesignerFolder>
<RootNamespace>
bug13338
</RootNamespace>
<AssemblyName>
bug13338
</AssemblyName>
<TargetFrameworkVersion>
v4.5
</TargetFrameworkVersion>
<FileAlignment>
512
</FileAlignment>
<ProjectTypeGuids>
{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
</ProjectTypeGuids>
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
<PropertyGroup
Condition=
" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "
>
<PlatformTarget>
AnyCPU
</PlatformTarget>
<DebugSymbols>
true
</DebugSymbols>
<DebugType>
full
</DebugType>
<Optimize>
false
</Optimize>
<OutputPath>
bin\Debug\
</OutputPath>
<DefineConstants>
DEBUG;TRACE
</DefineConstants>
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
<PropertyGroup
Condition=
" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "
>
<PlatformTarget>
AnyCPU
</PlatformTarget>
<DebugType>
pdbonly
</DebugType>
<Optimize>
true
</Optimize>
<OutputPath>
bin\Release\
</OutputPath>
<DefineConstants>
TRACE
</DefineConstants>
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference
Include=
"System"
>
<Aliases>
Sys1, Sys3
</Aliases>
</Reference>
<Reference
Include=
"System.Xml"
/>
</ItemGroup>
<Import
Project=
"$(MSBuildToolsPath)\Microsoft.CSharp.targets"
/>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
src/Workspaces/CoreTest/WorkspaceTests/MSBuildWorkspaceTests.cs
浏览文件 @
dafc24c2
...
...
@@ -77,6 +77,99 @@ public void TestOpenSolution_MultiProjectSolution()
Assert
.
Equal
(
5
,
compReferences
.
Count
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Workspace
)]
public
void
Test_SharedMetadataReferences
()
{
CreateFiles
(
GetMultiProjectSolutionFiles
());
var
sol
=
MSBuildWorkspace
.
Create
().
OpenSolutionAsync
(
GetSolutionFileName
(
"TestSolution.sln"
)).
Result
;
var
p0
=
sol
.
Projects
.
ElementAt
(
0
);
var
p1
=
sol
.
Projects
.
ElementAt
(
1
);
Assert
.
NotSame
(
p0
,
p1
);
var
p0mscorlib
=
GetMetadataReference
(
p0
,
"mscorlib"
);
var
p1mscorlib
=
GetMetadataReference
(
p1
,
"mscorlib"
);
Assert
.
NotNull
(
p0mscorlib
);
Assert
.
NotNull
(
p1mscorlib
);
// metadata references to mscorlib in both projects are the same
Assert
.
Same
(
p0mscorlib
,
p1mscorlib
);
}
private
static
MetadataReference
GetMetadataReference
(
Project
project
,
string
name
)
{
return
project
.
MetadataReferences
.
OfType
<
PortableExecutableReference
>().
SingleOrDefault
(
mr
=>
mr
.
FilePath
.
Contains
(
name
));
}
private
static
MetadataReference
GetMetadataReferenceByAlias
(
Project
project
,
string
aliasName
)
{
return
project
.
MetadataReferences
.
OfType
<
PortableExecutableReference
>().
SingleOrDefault
(
mr
=>
!
mr
.
Properties
.
Aliases
.
IsDefault
&&
mr
.
Properties
.
Aliases
.
Contains
(
aliasName
));
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Workspace
),
WorkItem
(
546171
,
"DevDiv"
)]
public
void
Test_SharedMetadataReferencesWithAliases
()
{
var
projPath1
=
@"CSharpProject\CSharpProject_ExternAlias.csproj"
;
var
projPath2
=
@"CSharpProject\CSharpProject_ExternAlias2.csproj"
;
var
files
=
new
FileSet
(
new
Dictionary
<
string
,
object
>
{
{
projPath1
,
GetResourceText
(
"CSharpProject_CSharpProject_ExternAlias.csproj"
)
},
{
projPath2
,
GetResourceText
(
"CSharpProject_CSharpProject_ExternAlias2.csproj"
)
},
{
@"CSharpProject\CSharpExternAlias.cs"
,
GetResourceText
(
"CSharpProject_CSharpExternAlias.cs"
)
},
});
CreateFiles
(
files
);
var
fullPath1
=
Path
.
Combine
(
this
.
SolutionDirectory
.
Path
,
projPath1
);
var
fullPath2
=
Path
.
Combine
(
this
.
SolutionDirectory
.
Path
,
projPath2
);
using
(
var
ws
=
MSBuildWorkspace
.
Create
())
{
var
proj1
=
ws
.
OpenProjectAsync
(
fullPath1
).
Result
;
var
proj2
=
ws
.
OpenProjectAsync
(
fullPath2
).
Result
;
var
p1Sys1
=
GetMetadataReferenceByAlias
(
proj1
,
"Sys1"
);
var
p1Sys2
=
GetMetadataReferenceByAlias
(
proj1
,
"Sys2"
);
var
p2Sys1
=
GetMetadataReferenceByAlias
(
proj2
,
"Sys1"
);
var
p2Sys3
=
GetMetadataReferenceByAlias
(
proj2
,
"Sys3"
);
Assert
.
NotNull
(
p1Sys1
);
Assert
.
NotNull
(
p1Sys2
);
Assert
.
NotNull
(
p2Sys1
);
Assert
.
NotNull
(
p2Sys3
);
// same filepath but different alias so they are not the same instance
Assert
.
NotSame
(
p1Sys1
,
p1Sys2
);
Assert
.
NotSame
(
p2Sys1
,
p2Sys3
);
// same filepath and alias so they are the same instance
Assert
.
Same
(
p1Sys1
,
p2Sys1
);
var
mdp1Sys1
=
GetMetadata
(
p1Sys1
);
var
mdp1Sys2
=
GetMetadata
(
p1Sys2
);
var
mdp2Sys1
=
GetMetadata
(
p2Sys1
);
var
mdp2Sys3
=
GetMetadata
(
p2Sys1
);
Assert
.
NotNull
(
mdp1Sys1
);
Assert
.
NotNull
(
mdp1Sys2
);
Assert
.
NotNull
(
mdp2Sys1
);
Assert
.
NotNull
(
mdp2Sys3
);
// all references to System.dll share the same metadata bytes
Assert
.
Same
(
mdp1Sys1
,
mdp1Sys2
);
Assert
.
Same
(
mdp1Sys1
,
mdp2Sys1
);
Assert
.
Same
(
mdp1Sys1
,
mdp2Sys3
);
}
}
private
Metadata
GetMetadata
(
MetadataReference
mref
)
{
var
fnGetMetadata
=
mref
.
GetType
().
GetMethod
(
"GetMetadata"
,
BindingFlags
.
Public
|
BindingFlags
.
NonPublic
|
BindingFlags
.
Instance
|
BindingFlags
.
FlattenHierarchy
);
return
fnGetMetadata
?.
Invoke
(
mref
,
null
)
as
Metadata
;
}
[
WorkItem
(
552981
,
"DevDiv"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Workspace
)]
public
void
TestOpenSolution_DuplicateProjectGuids
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录