Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
64133226
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,发现更多精彩内容 >>
提交
64133226
编写于
2月 14, 2017
作者:
J
Jason Malinowski
提交者:
GitHub
2月 14, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #17146 from dotnet/master
Merge master into dev15.1.x
上级
4799250a
7ca1b2ea
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
1989 addition
and
9 deletion
+1989
-9
src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTestBase.cs
...CSharp/Test/Semantic/Semantics/PatternMatchingTestBase.cs
+15
-0
src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests.cs
...rs/CSharp/Test/Semantic/Semantics/PatternMatchingTests.cs
+66
-0
src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests_Global.cs
...rp/Test/Semantic/Semantics/PatternMatchingTests_Global.cs
+1856
-0
src/Features/Core/Portable/Diagnostics/EngineV2/DiagnosticIncrementalAnalyzer.ProjectState.cs
...cs/EngineV2/DiagnosticIncrementalAnalyzer.ProjectState.cs
+4
-1
src/Test/Perf/Runner/Program.cs
src/Test/Perf/Runner/Program.cs
+7
-6
src/VisualStudio/Core/Impl/ProjectSystem/CPS/CPSProjectFactory.cs
...alStudio/Core/Impl/ProjectSystem/CPS/CPSProjectFactory.cs
+41
-2
未找到文件。
src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTestBase.cs
浏览文件 @
64133226
...
...
@@ -121,6 +121,16 @@ protected static void VerifyModelForDeclarationPatternDuplicateInSameScope(Seman
}
}
protected
static
void
VerifyNotAPatternField
(
SemanticModel
model
,
IdentifierNameSyntax
reference
)
{
var
symbol
=
model
.
GetSymbolInfo
(
reference
).
Symbol
;
Assert
.
NotEqual
(
SymbolKind
.
Field
,
symbol
.
Kind
);
Assert
.
Same
(
symbol
,
model
.
LookupSymbols
(
reference
.
SpanStart
,
name
:
reference
.
Identifier
.
ValueText
).
Single
());
Assert
.
True
(
model
.
LookupNames
(
reference
.
SpanStart
).
Contains
(
reference
.
Identifier
.
ValueText
));
}
protected
static
void
VerifyNotAPatternLocal
(
SemanticModel
model
,
IdentifierNameSyntax
reference
)
{
var
symbol
=
model
.
GetSymbolInfo
(
reference
).
Symbol
;
...
...
@@ -301,6 +311,11 @@ protected static void VerifyModelNotSupported(SemanticModel model, params Identi
}
}
protected
static
void
AssertNoGlobalStatements
(
SyntaxTree
tree
)
{
Assert
.
Empty
(
tree
.
GetRoot
().
DescendantNodes
().
OfType
<
GlobalStatementSyntax
>());
}
#
endregion
helpers
}
}
src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests.cs
浏览文件 @
64133226
...
...
@@ -795,6 +795,13 @@ static bool Dummy(int x)
var
compilation
=
CreateCompilationWithMscorlib45
(
source
,
options
:
TestOptions
.
DebugExe
);
CompileAndVerify
(
compilation
,
expectedOutput
:
@"1
True"
);
var
tree
=
compilation
.
SyntaxTrees
.
Single
();
var
model
=
compilation
.
GetSemanticModel
(
tree
);
var
x1Decl
=
GetPatternDeclaration
(
tree
,
"x1"
);
var
x1Ref
=
GetReferences
(
tree
,
"x1"
).
Single
();
VerifyModelForDeclarationPattern
(
model
,
x1Decl
,
x1Ref
);
}
[
Fact
]
...
...
@@ -902,6 +909,49 @@ static bool Print(object x)
}
}
[
Fact
]
public
void
Query_02
()
{
var
source
=
@"
using System.Linq;
public class X
{
public static void Main()
{
Test1();
}
static void Test1()
{
var res = from x1 in new[] { 1 is var y1 && Print(y1) ? 2 : 0}
select Print(x1);
res.ToArray();
}
static bool Print(object x)
{
System.Console.WriteLine(x);
return true;
}
}
"
;
var
compilation
=
CreateCompilationWithMscorlib45
(
source
,
new
[]
{
SystemCoreRef
},
options
:
TestOptions
.
DebugExe
,
parseOptions
:
TestOptions
.
Regular
);
CompileAndVerify
(
compilation
,
expectedOutput
:
@"1
2"
);
var
tree
=
compilation
.
SyntaxTrees
.
Single
();
var
model
=
compilation
.
GetSemanticModel
(
tree
);
var
yDecl
=
GetPatternDeclaration
(
tree
,
"y1"
);
var
yRef
=
GetReferences
(
tree
,
"y1"
).
Single
();
VerifyModelForDeclarationPattern
(
model
,
yDecl
,
yRef
);
}
[
Fact
]
public
void
ExpressionBodiedFunctions_01
()
{
...
...
@@ -2359,6 +2409,14 @@ static System.Collections.IEnumerable Dummy(object y, object z)
CompileAndVerify
(
compilation
,
expectedOutput
:
@"3
3"
);
var
tree
=
compilation
.
SyntaxTrees
.
Single
();
var
model
=
compilation
.
GetSemanticModel
(
tree
);
var
x1Decl
=
GetPatternDeclaration
(
tree
,
"x1"
);
var
x1Ref
=
GetReferences
(
tree
,
"x1"
).
ToArray
();
Assert
.
Equal
(
2
,
x1Ref
.
Length
);
VerifyModelForDeclarationPattern
(
model
,
x1Decl
,
x1Ref
);
}
[
Fact
]
...
...
@@ -2775,6 +2833,14 @@ static bool Dummy(object y, object z)
CompileAndVerify
(
compilation
,
expectedOutput
:
@"System.InvalidOperationException
System.InvalidOperationException"
);
var
tree
=
compilation
.
SyntaxTrees
.
Single
();
var
model
=
compilation
.
GetSemanticModel
(
tree
);
var
x1Decl
=
GetPatternDeclaration
(
tree
,
"x1"
);
var
x1Ref
=
GetReferences
(
tree
,
"x1"
).
ToArray
();
Assert
.
Equal
(
2
,
x1Ref
.
Length
);
VerifyModelForDeclarationPattern
(
model
,
x1Decl
,
x1Ref
);
}
[
Fact
]
...
...
src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests_Global.cs
浏览文件 @
64133226
此差异已折叠。
点击以展开。
src/Features/Core/Portable/Diagnostics/EngineV2/DiagnosticIncrementalAnalyzer.ProjectState.cs
浏览文件 @
64133226
...
...
@@ -242,7 +242,10 @@ public async Task MergeAsync(ActiveFileState state, Document document)
var
semantic
=
state
.
GetAnalysisData
(
AnalysisKind
.
Semantic
);
var
project
=
document
.
Project
;
var
fullAnalysis
=
ServiceFeatureOnOffOptions
.
IsClosedFileDiagnosticsEnabled
(
project
);
// if project didn't successfully loaded, then it is same as FSA off
var
fullAnalysis
=
ServiceFeatureOnOffOptions
.
IsClosedFileDiagnosticsEnabled
(
project
)
&&
await
project
.
HasSuccessfullyLoadedAsync
(
CancellationToken
.
None
).
ConfigureAwait
(
false
);
// keep from build flag if full analysis is off
var
fromBuild
=
fullAnalysis
?
false
:
lastResult
.
FromBuild
;
...
...
src/Test/Perf/Runner/Program.cs
浏览文件 @
64133226
...
...
@@ -24,6 +24,7 @@ public static int Main(string[] args)
string
submissionType
=
null
;
string
traceDestination
=
@"\\mlangfs1\public\basoundr\PerfTraces"
;
string
branch
=
null
;
string
searchDirectory
=
AppDomain
.
CurrentDomain
.
BaseDirectory
;
var
parameterOptions
=
new
OptionSet
()
{
...
...
@@ -33,8 +34,10 @@ public static int Main(string[] args)
{
"branch="
,
"name of the branch you are measuring on"
,
name
=>
{
branch
=
name
;
}
},
{
"ci-test"
,
"mention that we are running in the continuous integration lab"
,
_
=>
isCiTest
=
true
},
{
"no-trace-upload"
,
"disable the uploading of traces"
,
_
=>
shouldUploadTrace
=
false
},
{
"trace-upload_destination"
,
"set the trace uploading destination"
,
loc
=>
{
traceDestination
=
loc
;
}}
{
"trace-upload_destination="
,
"set the trace uploading destination"
,
loc
=>
{
traceDestination
=
loc
;
}
},
{
"search-directory="
,
"the directory to recursively search for tests"
,
dir
=>
{
searchDirectory
=
dir
;
}
}
};
parameterOptions
.
Parse
(
args
);
if
(
shouldReportBenchview
)
...
...
@@ -48,7 +51,7 @@ public static int Main(string[] args)
}
Cleanup
();
AsyncMain
(
isCiTest
).
GetAwaiter
().
GetResult
();
AsyncMain
(
isCiTest
,
searchDirectory
).
GetAwaiter
().
GetResult
();
if
(
isCiTest
)
{
...
...
@@ -139,12 +142,10 @@ private static void Cleanup()
}
}
private
static
async
Task
AsyncMain
(
bool
isRunningUnderCI
)
private
static
async
Task
AsyncMain
(
bool
isRunningUnderCI
,
string
searchDirectory
)
{
RuntimeSettings
.
IsRunnerAttached
=
true
;
var
testDirectory
=
AppDomain
.
CurrentDomain
.
BaseDirectory
;
// Print message at startup
Log
(
"Starting Performance Test Run"
);
Log
(
"hash: "
+
FirstLine
(
StdoutFromOrDefault
(
"git"
,
"show --format=\"%h\" HEAD --"
,
"git missing"
)));
...
...
@@ -153,7 +154,7 @@ private static async Task AsyncMain(bool isRunningUnderCI)
var
testInstances
=
new
List
<
PerfTest
>();
// Find all the tests from inside of the csx files.
foreach
(
var
script
in
GetAllCsxRecursive
(
test
Directory
))
foreach
(
var
script
in
GetAllCsxRecursive
(
search
Directory
))
{
var
scriptName
=
Path
.
GetFileNameWithoutExtension
(
script
);
Log
(
$"Collecting tests from
{
scriptName
}
"
);
...
...
src/VisualStudio/Core/Impl/ProjectSystem/CPS/CPSProjectFactory.cs
浏览文件 @
64133226
...
...
@@ -5,6 +5,7 @@
using
System.Collections.Immutable
;
using
System.ComponentModel.Composition
;
using
Microsoft.CodeAnalysis
;
using
Microsoft.CodeAnalysis.Editor.Shared.Utilities
;
using
Microsoft.CodeAnalysis.Host
;
using
Microsoft.VisualStudio.LanguageServices.Implementation.TaskList
;
using
Microsoft.VisualStudio.LanguageServices.ProjectSystem
;
...
...
@@ -16,7 +17,7 @@
namespace
Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.CPS
{
[
Export
(
typeof
(
IWorkspaceProjectContextFactory
))]
internal
partial
class
CPSProjectFactory
:
IWorkspaceProjectContextFactory
internal
partial
class
CPSProjectFactory
:
ForegroundThreadAffinitizedObject
,
IWorkspaceProjectContextFactory
{
private
readonly
IServiceProvider
_serviceProvider
;
private
readonly
VisualStudioWorkspaceImpl
_visualStudioWorkspace
;
...
...
@@ -33,7 +34,8 @@ internal partial class CPSProjectFactory : IWorkspaceProjectContextFactory
public
CPSProjectFactory
(
SVsServiceProvider
serviceProvider
,
VisualStudioWorkspaceImpl
visualStudioWorkspace
,
HostDiagnosticUpdateSource
hostDiagnosticUpdateSource
)
HostDiagnosticUpdateSource
hostDiagnosticUpdateSource
)
:
base
(
assertIsForeground
:
false
)
{
_serviceProvider
=
serviceProvider
;
_visualStudioWorkspace
=
visualStudioWorkspace
;
...
...
@@ -43,6 +45,7 @@ internal partial class CPSProjectFactory : IWorkspaceProjectContextFactory
// internal for testing purposes only.
internal
static
CPSProject
CreateCPSProject
(
VisualStudioProjectTracker
projectTracker
,
IServiceProvider
serviceProvider
,
IVsHierarchy
hierarchy
,
string
projectDisplayName
,
string
projectFilePath
,
Guid
projectGuid
,
string
language
,
ICommandLineParserService
commandLineParserService
,
string
binOutputPath
)
{
// this only runs under unit test
return
new
CPSProject
(
projectTracker
,
reportExternalErrorCreatorOpt
:
null
,
hierarchy
:
hierarchy
,
language
:
language
,
serviceProvider
:
serviceProvider
,
visualStudioWorkspaceOpt
:
null
,
hostDiagnosticUpdateSourceOpt
:
null
,
projectDisplayName
:
projectDisplayName
,
projectFilePath
:
projectFilePath
,
projectGuid
:
projectGuid
,
...
...
@@ -57,6 +60,10 @@ internal static CPSProject CreateCPSProject(VisualStudioProjectTracker projectTr
object
hierarchy
,
string
binOutputPath
)
{
AssertIsForeground
();
EnsurePackageLoaded
(
languageName
);
// NOTE: It is acceptable for hierarchy to be null in Deferred Project Load scenarios.
var
vsHierarchy
=
hierarchy
as
IVsHierarchy
;
...
...
@@ -76,6 +83,10 @@ internal static CPSProject CreateCPSProject(VisualStudioProjectTracker projectTr
string
binOutputPath
,
ProjectExternalErrorReporter
errorReporter
)
{
AssertIsForeground
();
EnsurePackageLoaded
(
languageName
);
// NOTE: It is acceptable for hierarchy to be null in Deferred Project Load scenarios.
var
vsHierarchy
=
hierarchy
as
IVsHierarchy
;
...
...
@@ -94,5 +105,33 @@ private IVsReportExternalErrors GetExternalErrorReporter(ProjectId projectId, st
return
new
ProjectExternalErrorReporter
(
projectId
,
errorCodePrefix
,
_serviceProvider
);
}
private
void
EnsurePackageLoaded
(
string
language
)
{
// we need to make sure we load required packages which initialize VS related services
// such as OB, FAR, Error list, Msic workspace, solution crawler before actually
// set roslyn CPS up.
var
shell
=
(
IVsShell
)
_serviceProvider
.
GetService
(
typeof
(
SVsShell
));
if
(
shell
==
null
)
{
// no shell. can happen in unit test
return
;
}
IVsPackage
unused
;
switch
(
language
)
{
case
LanguageNames
.
CSharp
:
shell
.
LoadPackage
(
Guids
.
CSharpPackageId
,
out
unused
);
break
;
case
LanguageNames
.
VisualBasic
:
shell
.
LoadPackage
(
Guids
.
VisualBasicPackageId
,
out
unused
);
break
;
default
:
// by default, load roslyn package for things like typescript and etc
shell
.
LoadPackage
(
Guids
.
RoslynPackageId
,
out
unused
);
break
;
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录