Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
1f27d165
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,发现更多精彩内容 >>
提交
1f27d165
编写于
5月 01, 2015
作者:
M
Matt Warren
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Dont rely on link metdata being valid file path
上级
aae1ded0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
108 addition
and
13 deletion
+108
-13
src/Workspaces/Core/Desktop/Workspace/MSBuild/MSBuildWorkspace.cs
...spaces/Core/Desktop/Workspace/MSBuild/MSBuildWorkspace.cs
+32
-13
src/Workspaces/CoreTest/ServicesTest.csproj
src/Workspaces/CoreTest/ServicesTest.csproj
+5
-0
src/Workspaces/CoreTest/TestFiles/CSharpProject_CSharpProject_BadLink.csproj
...Test/TestFiles/CSharpProject_CSharpProject_BadLink.csproj
+58
-0
src/Workspaces/CoreTest/WorkspaceTests/MSBuildWorkspaceTests.cs
...rkspaces/CoreTest/WorkspaceTests/MSBuildWorkspaceTests.cs
+13
-0
未找到文件。
src/Workspaces/Core/Desktop/Workspace/MSBuild/MSBuildWorkspace.cs
浏览文件 @
1f27d165
...
...
@@ -636,7 +636,7 @@ private async Task<ProjectId> LoadProjectAsync(string projectFilePath, IProjectF
var
projectId
=
this
.
GetOrCreateProjectId
(
projectFilePath
);
var
n
ame
=
Path
.
GetFileNameWithoutExtension
(
projectFilePath
);
var
projectN
ame
=
Path
.
GetFileNameWithoutExtension
(
projectFilePath
);
var
projectFile
=
await
loader
.
LoadProjectFileAsync
(
projectFilePath
,
_properties
,
cancellationToken
).
ConfigureAwait
(
false
);
var
projectFileInfo
=
await
projectFile
.
GetProjectFileInfoAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
...
...
@@ -660,10 +660,14 @@ private async Task<ProjectId> LoadProjectAsync(string projectFilePath, IProjectF
var
docs
=
new
List
<
DocumentInfo
>();
foreach
(
var
docFileInfo
in
docFileInfos
)
{
string
name
;
ImmutableArray
<
string
>
folders
;
GetDocumentNameAndFolders
(
docFileInfo
.
LogicalPath
,
out
name
,
out
folders
);
docs
.
Add
(
DocumentInfo
.
Create
(
DocumentId
.
CreateNewId
(
projectId
,
debugName
:
docFileInfo
.
FilePath
),
Path
.
GetFileName
(
docFileInfo
.
LogicalPath
)
,
GetDocumentFolders
(
docFileInfo
.
LogicalPath
)
,
name
,
folders
,
projectFile
.
GetSourceCodeKind
(
docFileInfo
.
FilePath
),
new
FileTextLoader
(
docFileInfo
.
FilePath
,
defaultEncoding
),
docFileInfo
.
FilePath
,
...
...
@@ -673,10 +677,14 @@ private async Task<ProjectId> LoadProjectAsync(string projectFilePath, IProjectF
var
additonalDocs
=
new
List
<
DocumentInfo
>();
foreach
(
var
docFileInfo
in
projectFileInfo
.
AdditionalDocuments
)
{
string
name
;
ImmutableArray
<
string
>
folders
;
GetDocumentNameAndFolders
(
docFileInfo
.
LogicalPath
,
out
name
,
out
folders
);
additonalDocs
.
Add
(
DocumentInfo
.
Create
(
DocumentId
.
CreateNewId
(
projectId
,
debugName
:
docFileInfo
.
FilePath
),
Path
.
GetFileName
(
docFileInfo
.
LogicalPath
)
,
GetDocumentFolders
(
docFileInfo
.
LogicalPath
)
,
name
,
folders
,
SourceCodeKind
.
Regular
,
new
FileTextLoader
(
docFileInfo
.
FilePath
,
defaultEncoding
),
docFileInfo
.
FilePath
,
...
...
@@ -709,7 +717,7 @@ private async Task<ProjectId> LoadProjectAsync(string projectFilePath, IProjectF
ProjectInfo
.
Create
(
projectId
,
version
,
n
ame
,
projectN
ame
,
assemblyName
,
loader
.
Language
,
projectFilePath
,
...
...
@@ -746,18 +754,29 @@ private static Encoding GetDefaultEncoding(int codePage)
}
}
private
static
readonly
char
[]
s_directorySplitChars
=
new
char
[]
{
Path
.
DirectorySeparatorChar
};
private
static
readonly
char
[]
s_directorySplitChars
=
new
char
[]
{
Path
.
DirectorySeparatorChar
,
Path
.
AltDirectorySeparatorChar
};
private
static
ImmutableArray
<
string
>
GetDocumentFolders
(
string
logicalPath
)
private
static
void
GetDocumentNameAndFolders
(
string
logicalPath
,
out
string
name
,
out
ImmutableArray
<
string
>
folders
)
{
var
logicalDirectory
=
Path
.
GetDirectoryName
(
logicalPath
);
var
pathNames
=
logicalPath
.
Split
(
s_directorySplitChars
,
StringSplitOptions
.
RemoveEmptyEntries
);
if
(
pathNames
.
Length
>
0
)
{
if
(
pathNames
.
Length
>
1
)
{
folders
=
pathNames
.
Take
(
pathNames
.
Length
-
1
).
ToImmutableArray
();
}
else
{
folders
=
ImmutableArray
.
Create
<
string
>();
}
if
(!
string
.
IsNullOrEmpty
(
logicalDirectory
))
name
=
pathNames
[
pathNames
.
Length
-
1
];
}
else
{
return
logicalDirectory
.
Split
(
s_directorySplitChars
,
StringSplitOptions
.
None
).
ToImmutableArray
();
name
=
logicalPath
;
folders
=
ImmutableArray
.
Create
<
string
>();
}
return
ImmutableArray
.
Create
<
string
>();
}
private
void
CheckDocuments
(
IEnumerable
<
DocumentFileInfo
>
docs
,
string
projectFilePath
,
ProjectId
projectId
)
...
...
src/Workspaces/CoreTest/ServicesTest.csproj
浏览文件 @
1f27d165
...
...
@@ -311,6 +311,11 @@
<ItemGroup>
<EmbeddedResource
Include=
"TestFiles\VisualBasicProject_VisualBasicProject_WithoutVBTargetsImported.vbproj"
/>
</ItemGroup>
<ItemGroup>
<EmbeddedResource
Include=
"TestFiles\CSharpProject_CSharpProject_BadLink.csproj"
>
<SubType>
Designer
</SubType>
</EmbeddedResource>
</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_BadLink.csproj
0 → 100644
浏览文件 @
1f27d165
<?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"
>
<PropertyGroup>
<Configuration
Condition=
" '$(Configuration)' == '' "
>
Debug
</Configuration>
<Platform
Condition=
" '$(Platform)' == '' "
>
AnyCPU
</Platform>
<ProductVersion>
8.0.30703
</ProductVersion>
<SchemaVersion>
2.0
</SchemaVersion>
<ProjectGuid>
{686DD036-86AA-443E-8A10-DDB43266A8C4}
</ProjectGuid>
<OutputType>
Library
</OutputType>
<AppDesignerFolder>
Properties
</AppDesignerFolder>
<RootNamespace>
CSharpProject
</RootNamespace>
<AssemblyName>
CSharpProject
</AssemblyName>
<TargetFrameworkVersion>
v4.0
</TargetFrameworkVersion>
<FileAlignment>
512
</FileAlignment>
<AssemblyOriginatorKeyFile>
snKey.snk
</AssemblyOriginatorKeyFile>
<MyProperty>
xyz
</MyProperty>
</PropertyGroup>
<PropertyGroup
Condition=
" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "
>
<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' "
>
<DebugType>
pdbonly
</DebugType>
<Optimize>
true
</Optimize>
<OutputPath>
bin\Release\
</OutputPath>
<DefineConstants>
TRACE
</DefineConstants>
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference
Include=
"Microsoft.CSharp"
/>
<Reference
Include=
"System"
/>
<Reference
Include=
"System.Core"
/>
</ItemGroup>
<ItemGroup>
<MyNode
Include=
"CSharpClass.cs"
/>
<MyNode
Include=
"Properties\AssemblyInfo.cs"
/>
</ItemGroup>
<ItemGroup>
<Compile
Include=
"@(MyNode)"
>
<Link>
$([MSBuild]::MakeRelative($(MyProperty), %(Identity))
</Link>
</Compile>
</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
浏览文件 @
1f27d165
...
...
@@ -2607,5 +2607,18 @@ public void TestAddRemoveProjectReference()
Assert
.
Equal
(
true
,
projFileText
.
Contains
(
@"<ProjectReference Include=""..\CSharpProject\CSharpProject.csproj"">"
));
}
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Workspace
)]
[
WorkItem
(
1101040
)]
public
void
TestOpenProject_BadLink
()
{
CreateFiles
(
GetSimpleCSharpSolutionFiles
()
.
WithFile
(
@"CSharpProject\CSharpProject.csproj"
,
GetResourceText
(
@"CSharpProject_CSharpProject_BadLink.csproj"
)));
var
ws
=
MSBuildWorkspace
.
Create
();
var
proj
=
ws
.
OpenProjectAsync
(
GetSolutionFileName
(
@"CSharpProject\CSharpProject.csproj"
)).
Result
;
var
docs
=
proj
.
Documents
.
ToList
();
Assert
.
Equal
(
3
,
docs
.
Count
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录