Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
f7059b37
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,发现更多精彩内容 >>
提交
f7059b37
编写于
3月 20, 2020
作者:
C
Chris Sienkiewicz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert the temporary IDE changes for preview
上级
b2ff2889
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
42 addition
and
74 deletion
+42
-74
src/Features/Core/Portable/Diagnostics/AnalyzerHelper.cs
src/Features/Core/Portable/Diagnostics/AnalyzerHelper.cs
+1
-1
src/Workspaces/CSharp/Portable/Workspace/LanguageServices/CSharpCompilationFactoryService.cs
...space/LanguageServices/CSharpCompilationFactoryService.cs
+0
-13
src/Workspaces/Core/Portable/Workspace/Host/CompilationFactory/ICompilationFactoryService.cs
...ace/Host/CompilationFactory/ICompilationFactoryService.cs
+0
-4
src/Workspaces/Core/Portable/Workspace/Solution/ProjectState.cs
...rkspaces/Core/Portable/Workspace/Solution/ProjectState.cs
+8
-0
src/Workspaces/Core/Portable/Workspace/Solution/Solution.cs
src/Workspaces/Core/Portable/Workspace/Solution/Solution.cs
+9
-1
src/Workspaces/Core/Portable/Workspace/Solution/SolutionState.cs
...kspaces/Core/Portable/Workspace/Solution/SolutionState.cs
+24
-49
src/Workspaces/VisualBasic/Portable/Workspace/LanguageServices/VisualBasicCompilationFactoryService.vb
.../LanguageServices/VisualBasicCompilationFactoryService.vb
+0
-6
未找到文件。
src/Features/Core/Portable/Diagnostics/AnalyzerHelper.cs
浏览文件 @
f7059b37
...
...
@@ -264,7 +264,7 @@ public static IEnumerable<AnalyzerPerformanceInfo> ToAnalyzerPerformanceInfo(thi
}
Contract
.
ThrowIfFalse
(
project
.
SupportsCompilation
);
//AssertCompilation(project, compilation); //PROTOTYPE: this assert no longer holds
AssertCompilation
(
project
,
compilation
);
// in IDE, we always set concurrentAnalysis == false otherwise, we can get into thread starvation due to
// async being used with synchronous blocking concurrency.
...
...
src/Workspaces/CSharp/Portable/Workspace/LanguageServices/CSharpCompilationFactoryService.cs
浏览文件 @
f7059b37
...
...
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using
System
;
using
System.Collections.Immutable
;
using
System.Composition
;
using
Microsoft.CodeAnalysis.Host
;
using
Microsoft.CodeAnalysis.Host.Mef
;
...
...
@@ -52,17 +51,5 @@ CompilationOptions ICompilationFactoryService.GetDefaultCompilationOptions()
{
return
s_defaultOptions
;
}
//PROTOTYPE
#
nullable
enable
GeneratorDriver
?
ICompilationFactoryService
.
CreateGeneratorDriver
(
Compilation
compilation
,
ParseOptions
parseOptions
,
ImmutableArray
<
ISourceGenerator
>
generators
,
ImmutableArray
<
AdditionalText
>
additionalTexts
)
{
// PROTOTYPE: for now we gate behind langver == preview. We'll remove this before final shipping, as the feature is langver agnostic
if
(((
CSharpParseOptions
)
parseOptions
).
LanguageVersion
!=
LanguageVersion
.
Preview
)
{
return
null
;
}
return
new
CSharpGeneratorDriver
(
compilation
,
parseOptions
,
generators
,
additionalTexts
);
}
}
}
src/Workspaces/Core/Portable/Workspace/Host/CompilationFactory/ICompilationFactoryService.cs
浏览文件 @
f7059b37
...
...
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using
System
;
using
System.Collections.Immutable
;
namespace
Microsoft.CodeAnalysis.Host
{
...
...
@@ -14,8 +13,5 @@ internal interface ICompilationFactoryService : ILanguageService
Compilation
GetCompilationFromCompilationReference
(
MetadataReference
reference
);
bool
IsCompilationReference
(
MetadataReference
reference
);
CompilationOptions
GetDefaultCompilationOptions
();
// PROTOTYPE: an easy way to get a generator driver into the IDE layer
GeneratorDriver
CreateGeneratorDriver
(
Compilation
compilation
,
ParseOptions
parseOptions
,
ImmutableArray
<
ISourceGenerator
>
generators
,
ImmutableArray
<
AdditionalText
>
additionalTexts
);
}
}
src/Workspaces/Core/Portable/Workspace/Solution/ProjectState.cs
浏览文件 @
f7059b37
...
...
@@ -699,6 +699,14 @@ public ProjectState WithMetadataReferences(IEnumerable<MetadataReference> metada
projectInfo
:
this
.
ProjectInfo
.
WithMetadataReferences
(
metadataReferences
).
WithVersion
(
this
.
Version
.
GetNewerVersion
()));
}
public
ProjectState
AddAnalyzerReference
(
AnalyzerReference
analyzerReference
)
{
Debug
.
Assert
(!
this
.
AnalyzerReferences
.
Contains
(
analyzerReference
));
return
this
.
With
(
projectInfo
:
this
.
ProjectInfo
.
WithAnalyzerReferences
(
this
.
AnalyzerReferences
.
ToImmutableArray
().
Add
(
analyzerReference
)).
WithVersion
(
this
.
Version
.
GetNewerVersion
()));
}
public
ProjectState
RemoveAnalyzerReference
(
AnalyzerReference
analyzerReference
)
{
Debug
.
Assert
(
this
.
AnalyzerReferences
.
Contains
(
analyzerReference
));
...
...
src/Workspaces/Core/Portable/Workspace/Solution/Solution.cs
浏览文件 @
f7059b37
...
...
@@ -592,7 +592,15 @@ public Solution WithProjectMetadataReferences(ProjectId projectId, IEnumerable<M
/// specified analyzer reference.
/// </summary>
public
Solution
AddAnalyzerReference
(
ProjectId
projectId
,
AnalyzerReference
analyzerReference
)
=>
AddAnalyzerReferences
(
projectId
,
ImmutableArray
.
Create
(
analyzerReference
));
{
var
newState
=
_state
.
AddAnalyzerReference
(
projectId
,
analyzerReference
);
if
(
newState
==
_state
)
{
return
this
;
}
return
new
Solution
(
newState
);
}
/// <summary>
/// Create a new solution instance with the project specified updated to include the
...
...
src/Workspaces/Core/Portable/Workspace/Solution/SolutionState.cs
浏览文件 @
f7059b37
...
...
@@ -48,9 +48,6 @@ internal partial class SolutionState
// Values for all these are created on demand.
private
ImmutableDictionary
<
ProjectId
,
CompilationTracker
>
_projectIdToTrackerMap
;
// PROTOTYPE: create a generator driver per-project
private
ImmutableDictionary
<
ProjectId
,
GeneratorDriver
>
_projectIdToGeneratorDriverMap
;
// Checksums for this solution state
private
readonly
ValueSource
<
SolutionStateChecksums
>
_lazyChecksums
;
...
...
@@ -63,7 +60,6 @@ internal partial class SolutionState
SerializableOptionSet
options
,
ImmutableDictionary
<
ProjectId
,
ProjectState
>
idToProjectStateMap
,
ImmutableDictionary
<
ProjectId
,
CompilationTracker
>
projectIdToTrackerMap
,
ImmutableDictionary
<
ProjectId
,
GeneratorDriver
>
projectIdToGeneratorDriverMap
,
ImmutableDictionary
<
string
,
ImmutableArray
<
DocumentId
>>
filePathToDocumentIdsMap
,
ProjectDependencyGraph
dependencyGraph
)
{
...
...
@@ -75,7 +71,6 @@ internal partial class SolutionState
Options
=
options
;
_projectIdToProjectStateMap
=
idToProjectStateMap
;
_projectIdToTrackerMap
=
projectIdToTrackerMap
;
_projectIdToGeneratorDriverMap
=
projectIdToGeneratorDriverMap
;
_filePathToDocumentIdsMap
=
filePathToDocumentIdsMap
;
_dependencyGraph
=
dependencyGraph
;
...
...
@@ -99,7 +94,6 @@ internal partial class SolutionState
options
,
idToProjectStateMap
:
ImmutableDictionary
<
ProjectId
,
ProjectState
>.
Empty
,
projectIdToTrackerMap
:
ImmutableDictionary
<
ProjectId
,
CompilationTracker
>.
Empty
,
projectIdToGeneratorDriverMap
:
ImmutableDictionary
<
ProjectId
,
GeneratorDriver
>.
Empty
,
filePathToDocumentIdsMap
:
ImmutableDictionary
.
Create
<
string
,
ImmutableArray
<
DocumentId
>>(
StringComparer
.
OrdinalIgnoreCase
),
dependencyGraph
:
ProjectDependencyGraph
.
Empty
)
{
...
...
@@ -179,7 +173,6 @@ private void CheckInvariants()
SerializableOptionSet
?
options
=
null
,
ImmutableDictionary
<
ProjectId
,
ProjectState
>?
idToProjectStateMap
=
null
,
ImmutableDictionary
<
ProjectId
,
CompilationTracker
>?
projectIdToTrackerMap
=
null
,
ImmutableDictionary
<
ProjectId
,
GeneratorDriver
>?
projectIdToGeneratorDriverMap
=
null
,
ImmutableDictionary
<
string
,
ImmutableArray
<
DocumentId
>>?
filePathToDocumentIdsMap
=
null
,
ProjectDependencyGraph
?
dependencyGraph
=
null
)
{
...
...
@@ -191,7 +184,6 @@ private void CheckInvariants()
options
??=
Options
.
WithLanguages
(
GetProjectLanguages
(
idToProjectStateMap
));
projectIdToTrackerMap
??=
_projectIdToTrackerMap
;
filePathToDocumentIdsMap
??=
_filePathToDocumentIdsMap
;
projectIdToGeneratorDriverMap
??=
_projectIdToGeneratorDriverMap
;
dependencyGraph
??=
_dependencyGraph
;
if
(
branchId
==
_branchId
&&
...
...
@@ -216,7 +208,6 @@ private void CheckInvariants()
options
,
idToProjectStateMap
,
projectIdToTrackerMap
,
projectIdToGeneratorDriverMap
,
filePathToDocumentIdsMap
,
dependencyGraph
);
}
...
...
@@ -242,7 +233,6 @@ private void CheckInvariants()
Options
,
_projectIdToProjectStateMap
,
_projectIdToTrackerMap
,
_projectIdToGeneratorDriverMap
,
_filePathToDocumentIdsMap
,
_dependencyGraph
);
}
...
...
@@ -1078,6 +1068,26 @@ public SolutionState WithProjectMetadataReferences(ProjectId projectId, IEnumera
return
this
.
ForkProject
(
this
.
GetProjectState
(
projectId
)!.
WithMetadataReferences
(
metadataReferences
));
}
/// <summary>
/// Create a new solution instance with the project specified updated to include the
/// specified analyzer reference.
/// </summary>
public
SolutionState
AddAnalyzerReference
(
ProjectId
projectId
,
AnalyzerReference
analyzerReference
)
{
if
(
projectId
==
null
)
{
throw
new
ArgumentNullException
(
nameof
(
projectId
));
}
if
(
analyzerReference
==
null
)
{
throw
new
ArgumentNullException
(
nameof
(
analyzerReference
));
}
CheckContainsProject
(
projectId
);
return
this
.
ForkProject
(
this
.
GetProjectState
(
projectId
)!.
AddAnalyzerReference
(
analyzerReference
));
}
/// <summary>
/// Create a new solution instance with the project specified updated to include the
/// specified analyzer references.
...
...
@@ -1099,13 +1109,6 @@ public SolutionState AddAnalyzerReferences(ProjectId projectId, IEnumerable<Anal
return
this
;
}
//PROTOTYPE
if
(
_projectIdToGeneratorDriverMap
.
TryGetValue
(
projectId
,
out
var
driver
))
{
driver
=
driver
.
AddGenerators
(
analyzerReferences
.
SelectMany
(
r
=>
r
.
GetGenerators
()).
ToImmutableArray
());
_projectIdToGeneratorDriverMap
=
_projectIdToGeneratorDriverMap
.
SetItem
(
projectId
,
driver
);
}
CheckContainsProject
(
projectId
);
return
this
.
ForkProject
(
this
.
GetProjectState
(
projectId
)!.
AddAnalyzerReferences
(
analyzerReferences
));
}
...
...
@@ -1127,14 +1130,6 @@ public SolutionState RemoveAnalyzerReference(ProjectId projectId, AnalyzerRefere
}
CheckContainsProject
(
projectId
);
//PROTOTYPE:
if
(
_projectIdToGeneratorDriverMap
.
TryGetValue
(
projectId
,
out
var
driver
))
{
driver
=
driver
.
RemoveGenerators
(
analyzerReference
.
GetGenerators
());
_projectIdToGeneratorDriverMap
=
_projectIdToGeneratorDriverMap
.
SetItem
(
projectId
,
driver
);
}
return
this
.
ForkProject
(
this
.
GetProjectState
(
projectId
)!.
RemoveAnalyzerReference
(
analyzerReference
));
}
...
...
@@ -1823,31 +1818,11 @@ public bool TryGetCompilation(ProjectId projectId, [NotNullWhen(returnValue: tru
/// <remarks>
/// The compilation is guaranteed to have a syntax tree for each document of the project.
/// </remarks>
public
async
Task
<
Compilation
?>
GetCompilationAsync
(
ProjectState
project
,
CancellationToken
cancellationToken
)
public
Task
<
Compilation
?>
GetCompilationAsync
(
ProjectState
project
,
CancellationToken
cancellationToken
)
{
if
(
project
.
SupportsCompilation
)
{
var
comp
=
await
GetCompilationTracker
(
project
.
Id
).
GetCompilationAsync
(
this
,
cancellationToken
).
ConfigureAwait
(
false
);
// PROTOTYPE: either get an existing generator, or create a new one
GeneratorDriver
?
driver
=
_projectIdToGeneratorDriverMap
.
ContainsKey
(
project
.
Id
)
?
_projectIdToGeneratorDriverMap
[
project
.
Id
]
:
project
.
LanguageServices
.
CompilationFactory
?.
CreateGeneratorDriver
(
comp
,
project
.
ParseOptions
,
generators
:
project
.
AnalyzerReferences
.
SelectMany
(
r
=>
r
.
GetGenerators
()).
ToImmutableArray
(),
additionalTexts
:
project
.
AdditionalDocumentStates
.
Values
.
SelectAsArray
<
TextDocumentState
,
AdditionalText
>(
d
=>
new
AdditionalTextWithState
(
d
)));
if
(
driver
is
object
)
{
// PROTOTYPE: obviously we don't want to run full generation everytime
// we should instead periodically run full generation, and TryApplyEdits as needed.
// For now this lets us imagine what the experience feels like in the IDE
driver
=
driver
.
RunFullGeneration
(
comp
,
out
comp
,
out
_
);
_projectIdToGeneratorDriverMap
=
_projectIdToGeneratorDriverMap
.
SetItem
(
project
.
Id
,
driver
);
}
return
comp
;
}
return
null
;
return
project
.
SupportsCompilation
?
GetCompilationTracker
(
project
.
Id
).
GetCompilationAsync
(
this
,
cancellationToken
).
AsNullable
()
:
SpecializedTasks
.
Null
<
Compilation
>();
}
/// <summary>
...
...
src/Workspaces/VisualBasic/Portable/Workspace/LanguageServices/VisualBasicCompilationFactoryService.vb
浏览文件 @
f7059b37
...
...
@@ -2,7 +2,6 @@
' The .NET Foundation licenses this file to you under the MIT license.
' See the LICENSE file in the project root for more information.
Imports
System.Collections.Immutable
Imports
System.Composition
Imports
Microsoft.CodeAnalysis.Host
Imports
Microsoft.CodeAnalysis.Host.Mef
...
...
@@ -64,10 +63,5 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Public
Function
GetDefaultCompilationOptions
()
As
CompilationOptions
Implements
ICompilationFactoryService
.
GetDefaultCompilationOptions
Return
s_defaultOptions
End
Function
'PROTOTYPE
Public
Function
CreateGeneratorDriver
(
compilation
As
Compilation
,
parseOptions
As
ParseOptions
,
generators
As
ImmutableArray
(
Of
ISourceGenerator
),
additionalTexts
As
ImmutableArray
(
Of
AdditionalText
))
As
GeneratorDriver
Implements
ICompilationFactoryService
.
CreateGeneratorDriver
Return
Nothing
End
Function
End
Class
End
Namespace
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录