Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
0576aa01
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,发现更多精彩内容 >>
提交
0576aa01
编写于
9月 01, 2015
作者:
M
Matt Warren
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4791 from mattwar/Bug3931
Fix check for missing/unsupported language
上级
4659a768
a40306e7
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
88 addition
and
0 deletion
+88
-0
src/Workspaces/Core/Desktop/PublicAPI.Unshipped.txt
src/Workspaces/Core/Desktop/PublicAPI.Unshipped.txt
+1
-0
src/Workspaces/Core/Desktop/Workspace/MSBuild/MSBuildProjectLoader.cs
...es/Core/Desktop/Workspace/MSBuild/MSBuildProjectLoader.cs
+15
-0
src/Workspaces/Core/Desktop/Workspace/MSBuild/MSBuildWorkspace.cs
...spaces/Core/Desktop/Workspace/MSBuild/MSBuildWorkspace.cs
+9
-0
src/Workspaces/CoreTest/WorkspaceTests/MSBuildWorkspaceTests.cs
...rkspaces/CoreTest/WorkspaceTests/MSBuildWorkspaceTests.cs
+63
-0
未找到文件。
src/Workspaces/Core/Desktop/PublicAPI.Unshipped.txt
浏览文件 @
0576aa01
...
...
@@ -8,3 +8,4 @@ Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.MSBuildProjectLoader(Microso
Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.Properties.get -> System.Collections.Immutable.ImmutableDictionary<string, string>
Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.SkipUnrecognizedProjects.get -> bool
Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.SkipUnrecognizedProjects.set -> void
static Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.Create(Microsoft.CodeAnalysis.Host.HostServices hostServices) -> Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace
\ No newline at end of file
src/Workspaces/Core/Desktop/Workspace/MSBuild/MSBuildProjectLoader.cs
浏览文件 @
0576aa01
...
...
@@ -716,6 +716,21 @@ private bool TryGetLoaderFromProjectPath(string projectFilePath, ReportMode mode
}
}
// since we have both C# and VB loaders in this same library, it no longer indicates whether we have full language support available.
if
(
loader
!=
null
)
{
language
=
loader
.
Language
;
// check for command line parser existing... if not then error.
var
commandLineParser
=
_workspace
.
Services
.
GetLanguageServices
(
language
).
GetService
<
ICommandLineParserService
>();
if
(
commandLineParser
==
null
)
{
loader
=
null
;
this
.
ReportFailure
(
mode
,
string
.
Format
(
WorkspacesResources
.
CannotOpenProjectUnsupportedLanguage
,
projectFilePath
,
language
));
return
false
;
}
}
return
loader
!=
null
;
}
}
...
...
src/Workspaces/Core/Desktop/Workspace/MSBuild/MSBuildWorkspace.cs
浏览文件 @
0576aa01
...
...
@@ -60,6 +60,15 @@ public static MSBuildWorkspace Create(IDictionary<string, string> properties)
return
Create
(
properties
,
DesktopMefHostServices
.
DefaultServices
);
}
/// <summary>
/// Create a new instance of a workspace that can be populated by opening solution and project files.
/// </summary>
/// <param name="hostServices">The <see cref="HostServices"/> used to configure this workspace.</param>
public
static
MSBuildWorkspace
Create
(
HostServices
hostServices
)
{
return
Create
(
ImmutableDictionary
<
string
,
string
>.
Empty
,
hostServices
);
}
/// <summary>
/// Create a new instance of a workspace that can be populated by opening solution and project files.
/// </summary>
...
...
src/Workspaces/CoreTest/WorkspaceTests/MSBuildWorkspaceTests.cs
浏览文件 @
0576aa01
...
...
@@ -11,6 +11,8 @@
using
System.Xml.Linq
;
using
Microsoft.CodeAnalysis.CSharp.Syntax
;
using
Microsoft.CodeAnalysis.Diagnostics
;
using
Microsoft.CodeAnalysis.Host
;
using
Microsoft.CodeAnalysis.Host.Mef
;
using
Microsoft.CodeAnalysis.MSBuild
;
using
Microsoft.CodeAnalysis.Test.Utilities
;
using
Microsoft.CodeAnalysis.Text
;
...
...
@@ -1031,6 +1033,67 @@ public void TestOpenSolution_WithUnrecognizedProjectTypeGuidAndUnrecognizedExten
});
}
private
HostServices
hostServicesWithoutCSharp
=
MefHostServices
.
Create
(
MefHostServices
.
DefaultAssemblies
.
Where
(
a
=>
!
a
.
FullName
.
Contains
(
"CSharp"
)));
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Workspace
)]
[
WorkItem
(
3931
,
"https://github.com/dotnet/roslyn/issues/3931"
)]
public
void
TestOpenSolution_WithMissingLanguageLibraries_WithSkipFalse_Throws
()
{
// proves that if the language libaries are missing then the appropriate error occurs
CreateFiles
(
GetSimpleCSharpSolutionFiles
());
AssertThrows
<
InvalidOperationException
>(()
=>
{
var
ws
=
MSBuildWorkspace
.
Create
(
hostServicesWithoutCSharp
);
ws
.
SkipUnrecognizedProjects
=
false
;
var
solution
=
ws
.
OpenSolutionAsync
(
GetSolutionFileName
(
@"TestSolution.sln"
)).
Result
;
},
e
=>
{
Assert
.
Equal
(
true
,
e
.
Message
.
Contains
(
"extension"
));
});
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Workspace
)]
[
WorkItem
(
3931
,
"https://github.com/dotnet/roslyn/issues/3931"
)]
public
void
TestOpenSolution_WithMissingLanguageLibraries_WithSkipTrue_SucceedsWithDiagnostic
()
{
// proves that if the language libaries are missing then the appropriate error occurs
CreateFiles
(
GetSimpleCSharpSolutionFiles
());
var
ws
=
MSBuildWorkspace
.
Create
(
hostServicesWithoutCSharp
);
ws
.
SkipUnrecognizedProjects
=
true
;
var
dx
=
new
List
<
WorkspaceDiagnostic
>();
ws
.
WorkspaceFailed
+=
delegate
(
object
sender
,
WorkspaceDiagnosticEventArgs
e
)
{
dx
.
Add
(
e
.
Diagnostic
);
};
var
solution
=
ws
.
OpenSolutionAsync
(
GetSolutionFileName
(
@"TestSolution.sln"
)).
Result
;
Assert
.
Equal
(
1
,
dx
.
Count
);
Assert
.
True
(
dx
[
0
].
Message
.
Contains
(
"extension"
));
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Workspace
)]
[
WorkItem
(
3931
,
"https://github.com/dotnet/roslyn/issues/3931"
)]
public
void
TestOpenProject_WithMissingLanguageLibraries_Throws
()
{
// proves that if the language libaries are missing then the appropriate error occurs
CreateFiles
(
GetSimpleCSharpSolutionFiles
());
AssertThrows
<
InvalidOperationException
>(()
=>
{
var
ws
=
MSBuildWorkspace
.
Create
(
hostServicesWithoutCSharp
);
var
project
=
ws
.
OpenProjectAsync
(
GetSolutionFileName
(
@"CSharpProject\CSharpProject.csproj"
)).
Result
;
},
e
=>
{
Assert
.
Equal
(
true
,
e
.
Message
.
Contains
(
"extension"
));
});
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Workspace
)]
public
void
TestOpenProject_WithInvalidFilePath_Fails
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录