Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
e123480f
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,发现更多精彩内容 >>
提交
e123480f
编写于
8月 26, 2014
作者:
B
Basoundr_ms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rollbacking changeset 1324466 to prevent build break. (changeset 1324482)
上级
e199c861
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
10 addition
and
110 deletion
+10
-110
Src/Workspaces/Core/Workspace/MSBuild/MSBuildWorkspace.cs
Src/Workspaces/Core/Workspace/MSBuild/MSBuildWorkspace.cs
+5
-87
Src/Workspaces/CoreTest/WorkspaceTests/MSBuildWorkspaceTests.cs
...rkspaces/CoreTest/WorkspaceTests/MSBuildWorkspaceTests.cs
+1
-15
Src/Workspaces/CoreTest/WorkspaceTests/SolutionParsingTests.cs
...orkspaces/CoreTest/WorkspaceTests/SolutionParsingTests.cs
+4
-8
未找到文件。
Src/Workspaces/Core/Workspace/MSBuild/MSBuildWorkspace.cs
浏览文件 @
e123480f
...
...
@@ -8,13 +8,10 @@
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
#if !MSBUILD12
using
Microsoft.Build.Construction
;
#endif
using
Microsoft.CodeAnalysis
;
using
Microsoft.CodeAnalysis.Diagnostics
;
using
Microsoft.CodeAnalysis.Host
;
using
Microsoft.CodeAnalysis.LanguageServices
;
using
Microsoft.CodeAnalysis.Text
;
using
Roslyn.Utilities
;
...
...
@@ -369,60 +366,6 @@ public async Task<Solution> OpenSolutionAsync(string solutionFilePath, Cancellat
}
VersionStamp
version
=
default
(
VersionStamp
);
#if !MSBUILD12
Microsoft
.
Build
.
Construction
.
SolutionFile
solutionFile
=
Microsoft
.
Build
.
Construction
.
SolutionFile
.
Parse
(
absoluteSolutionPath
);
var
reportMode
=
this
.
SkipUnrecognizedProjects
?
ReportMode
.
Log
:
ReportMode
.
Throw
;
var
invalidProjects
=
new
List
<
ProjectInSolution
>();
// seed loaders from known project types
using
(
this
.
dataGuard
.
DisposableWait
())
{
foreach
(
var
project
in
solutionFile
.
ProjectsInOrder
)
{
var
projectAbsolutePath
=
TryGetAbsolutePath
(
project
.
AbsolutePath
,
reportMode
);
if
(
projectAbsolutePath
!=
null
)
{
var
extension
=
Path
.
GetExtension
(
projectAbsolutePath
);
extension
=
extension
.
StartsWith
(
"."
)
?
extension
.
Substring
(
1
)
:
extension
;
var
loader
=
ProjectFileLoader
.
GetLoaderForProjectFileExtension
(
this
,
extension
);
if
(
loader
!=
null
)
{
this
.
projectPathToLoaderMap
[
projectAbsolutePath
]
=
loader
;
}
}
else
{
invalidProjects
.
Add
(
project
);
}
}
}
// a list to accumulate all the loaded projects
var
loadedProjects
=
new
List
<
ProjectInfo
>();
// load all the projects
foreach
(
var
project
in
solutionFile
.
ProjectsInOrder
)
{
cancellationToken
.
ThrowIfCancellationRequested
();
if
(!
invalidProjects
.
Contains
(
project
))
{
var
projectAbsolutePath
=
TryGetAbsolutePath
(
project
.
AbsolutePath
,
reportMode
);
if
(
projectAbsolutePath
!=
null
)
{
IProjectFileLoader
loader
;
if
(
TryGetLoaderFromProjectPath
(
projectAbsolutePath
,
reportMode
,
out
loader
))
{
// projects get added to 'loadedProjects' as side-effect
// never perfer metadata when loading solution, all projects get loaded if they can.
var
tmp
=
await
GetOrLoadProjectAsync
(
projectAbsolutePath
,
loader
,
preferMetadata
:
false
,
loadedProjects
:
loadedProjects
,
cancellationToken
:
cancellationToken
).
ConfigureAwait
(
false
);
}
}
}
}
#else
SolutionFile
solutionFile
=
null
;
using
(
var
reader
=
new
StreamReader
(
absoluteSolutionPath
))
...
...
@@ -473,7 +416,6 @@ public async Task<Solution> OpenSolutionAsync(string solutionFilePath, Cancellat
}
}
}
#endif
// construct workspace from loaded project infos
this
.
OnSolutionAdded
(
SolutionInfo
.
Create
(
SolutionId
.
CreateNewId
(
debugName
:
absoluteSolutionPath
),
version
,
absoluteSolutionPath
,
loadedProjects
));
...
...
@@ -518,30 +460,6 @@ public async Task<Project> OpenProjectAsync(string projectFilePath, Cancellation
return
null
;
}
private
string
TryGetAbsolutePath
(
string
path
,
ReportMode
mode
)
{
try
{
path
=
Path
.
GetFullPath
(
path
);
}
catch
(
Exception
)
{
ReportFailure
(
mode
,
string
.
Format
(
WorkspacesResources
.
InvalidProjectFilePath
,
path
));
return
null
;
}
if
(!
File
.
Exists
(
path
))
{
ReportFailure
(
mode
,
string
.
Format
(
WorkspacesResources
.
ProjectFileNotFound
,
path
),
msg
=>
new
FileNotFoundException
(
msg
));
return
null
;
}
return
path
;
}
private
void
UpdateReferencesAfterAdd
()
{
using
(
this
.
serializationLock
.
DisposableWait
())
...
...
@@ -845,9 +763,9 @@ private async Task<MetadataReference> GetProjectMetadata(string projectFilePath,
return
null
;
}
#endregion
#
endregion
#region Apply Changes
#
region
Apply
Changes
public
override
bool
CanApplyChange
(
ApplyChangesKind
feature
)
{
switch
(
feature
)
...
...
@@ -1052,5 +970,5 @@ private void DeleteDocumentFile(DocumentId documentId, string fullPath)
}
}
}
#endregion
#
endregion
}
\ No newline at end of file
Src/Workspaces/CoreTest/WorkspaceTests/MSBuildWorkspaceTests.cs
浏览文件 @
e123480f
...
...
@@ -666,19 +666,6 @@ public void TestOpenSolution_WithNonExistentProject_SkipFalse_Fails()
});
}
#if !MSBUILD12
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Workspace
)]
public
void
TestOpenSolution_WithUnrecognizedProjectFileExtension_Fails
()
{
// proves that for solution open, project type guid and extension are both necessary
CreateFiles
(
GetSimpleCSharpSolutionFiles
()
.
WithFile
(
@"TestSolution.sln"
,
GetResourceText
(
"TestSolution_CSharp_UnknownProjectExtension.sln"
))
.
WithFile
(
@"CSharpProject\CSharpProject.noproj"
,
GetResourceText
(
"CSharpProject_CSharpProject.csproj"
)));
var
solution
=
MSBuildWorkspace
.
Create
().
OpenSolutionAsync
(
GetSolutionFileName
(
@"TestSolution.sln"
)).
Result
;
Assert
.
Equal
(
0
,
solution
.
ProjectIds
.
Count
);
}
#else
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Workspace
)]
public
void
TestOpenSolution_WithUnrecognizedProjectFileExtension_Succeeds
()
{
...
...
@@ -690,7 +677,6 @@ public void TestOpenSolution_WithUnrecognizedProjectFileExtension_Succeeds()
var
solution
=
MSBuildWorkspace
.
Create
().
OpenSolutionAsync
(
GetSolutionFileName
(
@"TestSolution.sln"
)).
Result
;
Assert
.
Equal
(
1
,
solution
.
ProjectIds
.
Count
);
}
#endif
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Workspace
)]
public
void
TestOpenSolution_WithUnrecognizedProjectTypeGuidButRecognizedExtension_Succeeds
()
...
...
@@ -2136,7 +2122,7 @@ public void TestOpenSolution_SolutionFileHasEmptyLineBetweenProjectBlock()
var
solution
=
MSBuildWorkspace
.
Create
().
OpenSolutionAsync
(
GetSolutionFileName
(
"TestSolution.sln"
)).
Result
;
}
[
Fact
(
Skip
=
"531283"
)
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Workspace
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Workspace
)]
[
WorkItem
(
531283
,
"DevDiv"
)]
public
void
TestOpenSolution_SolutionFileHasMissingEndProject
()
{
...
...
Src/Workspaces/CoreTest/WorkspaceTests/SolutionParsingTests.cs
浏览文件 @
e123480f
...
...
@@ -11,9 +11,6 @@ namespace Roslyn.Editor.UnitTests.SolutionParsing
{
public
class
SolutionParsingTests
{
private
static
string
visualStudio2010
=
@"# Visual Studio 2010"
;
private
static
string
visualStudio2012
=
@"# Visual Studio 2012"
;
#if MSBUILD12
[
Fact
]
public
void
ParseEmptyFile
()
{
...
...
@@ -30,7 +27,7 @@ public void ParseEmptySolution()
{
var
emptySolution
=
@"
Microsoft Visual Studio Solution File, Format Version 11.00
"
+
visualStudio2010
+
@"
# Visual Studio 2010
Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
...
...
@@ -60,7 +57,7 @@ public void ParseVisualBasicConsoleApplicationSolution()
{
var
vbConsoleApplicationSolution
=
@"
Microsoft Visual Studio Solution File, Format Version 11.00
"
+
visualStudio2010
+
@"
# Visual Studio 2010
Project(""{F184B08F-C81C-45F6-A57F-5ABD9991F28F}"") = ""ConsoleApplication1"", ""ConsoleApplication1\ConsoleApplication1.vbproj"", ""{09BC9F5A-FBFA-4BEE-A13C-77A99C95D06B}""
EndProject
Global
...
...
@@ -113,7 +110,7 @@ public void ParseSolutionWithMissingWhiteSpaces()
{
var
vbConsoleApplicationSolution
=
@"
Microsoft Visual Studio Solution File, Format Version 11.00
"
+
visualStudio2010
+
@"
# Visual Studio 2010
Project(""{F184B08F-C81C-45F6-A57F-5ABD9991F28F}"") =""ConsoleApplication1"" , ""Console Application1\ConsoleApplication1.vbproj"",""{09BC9F5A-FBFA-4BEE-A13C-77A99C95D06B}""
EndProject
Global
...
...
@@ -149,7 +146,7 @@ public void ParseSolutionFileWithVisualStudioVersion()
{
var
vbConsoleApplicationSolution
=
@"
Microsoft Visual Studio Solution File, Format Version 12.00
"
+
visualStudio2012
+
@"
# Visual Studio 12
VisualStudioVersion = 12.0.20430.1 PREVIEW
MinimumVisualStudioVersion = 10.0.40219.1
Project(""{F184B08F-C81C-45F6-A57F-5ABD9991F28F}"") =""ConsoleApplication1"" , ""Console Application1\ConsoleApplication1.vbproj"",""{09BC9F5A-FBFA-4BEE-A13C-77A99C95D06B}""
...
...
@@ -190,6 +187,5 @@ private Microsoft.CodeAnalysis.MSBuild.SolutionFile Parse(StringReader stringRea
{
return
Microsoft
.
CodeAnalysis
.
MSBuild
.
SolutionFile
.
Parse
(
stringReader
);
}
#endif
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录