Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
e0d45543
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,发现更多精彩内容 >>
提交
e0d45543
编写于
11月 07, 2016
作者:
C
CyrusNajmabadi
提交者:
GitHub
11月 07, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15046 from CyrusNajmabadi/useOutVar
Use out-var in a few more cases.
上级
6d34ab68
76e0f7fc
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
59 addition
and
137 deletion
+59
-137
src/Workspaces/Core/Desktop/Execution/SerializationAnalyzerAssemblyLoader.cs
.../Desktop/Execution/SerializationAnalyzerAssemblyLoader.cs
+1
-2
src/Workspaces/Core/Desktop/SymbolSearch/Patching/Delta.cs
src/Workspaces/Core/Desktop/SymbolSearch/Patching/Delta.cs
+1
-3
src/Workspaces/Core/Desktop/SymbolSearch/SymbolSearchUpdateEngine.Update.cs
...e/Desktop/SymbolSearch/SymbolSearchUpdateEngine.Update.cs
+1
-3
src/Workspaces/Core/Desktop/SymbolSearch/SymbolSearchUpdateEngine.cs
...ces/Core/Desktop/SymbolSearch/SymbolSearchUpdateEngine.cs
+7
-16
src/Workspaces/Core/Desktop/Workspace/Esent/EsentPersistentStorage.cs
...es/Core/Desktop/Workspace/Esent/EsentPersistentStorage.cs
+13
-30
src/Workspaces/Core/Desktop/Workspace/Esent/EsentPersistentStorage_IdentifierTable.cs
...Workspace/Esent/EsentPersistentStorage_IdentifierTable.cs
+6
-12
src/Workspaces/Core/Desktop/Workspace/Esent/EsentStorage.OpenSession.cs
.../Core/Desktop/Workspace/Esent/EsentStorage.OpenSession.cs
+1
-2
src/Workspaces/Core/Desktop/Workspace/Esent/EsentStorage.cs
src/Workspaces/Core/Desktop/Workspace/Esent/EsentStorage.cs
+2
-5
src/Workspaces/Core/Desktop/Workspace/Host/Documentation/DocumentationProviderServiceFactory.cs
...Host/Documentation/DocumentationProviderServiceFactory.cs
+1
-3
src/Workspaces/Core/Desktop/Workspace/Host/Mef/MefV1HostServices.cs
...aces/Core/Desktop/Workspace/Host/Mef/MefV1HostServices.cs
+2
-4
src/Workspaces/Core/Desktop/Workspace/MSBuild/CSharp/CSharpProjectFileLoader.CSharpProjectFile.cs
...Build/CSharp/CSharpProjectFileLoader.CSharpProjectFile.cs
+1
-4
src/Workspaces/Core/Desktop/Workspace/MSBuild/MSBuildProjectLoader.cs
...es/Core/Desktop/Workspace/MSBuild/MSBuildProjectLoader.cs
+13
-32
src/Workspaces/Core/Desktop/Workspace/MSBuild/MSBuildWorkspace.cs
...spaces/Core/Desktop/Workspace/MSBuild/MSBuildWorkspace.cs
+2
-5
src/Workspaces/Core/Desktop/Workspace/MSBuild/ProjectFile/BuildTargets.cs
...ore/Desktop/Workspace/MSBuild/ProjectFile/BuildTargets.cs
+1
-2
src/Workspaces/Core/Desktop/Workspace/MSBuild/ProjectFile/ProjectFile.cs
...Core/Desktop/Workspace/MSBuild/ProjectFile/ProjectFile.cs
+3
-6
src/Workspaces/Core/Desktop/Workspace/SolutionSize/SolutionSizeTracker.cs
...ore/Desktop/Workspace/SolutionSize/SolutionSizeTracker.cs
+2
-4
src/Workspaces/Core/Desktop/Workspace/Storage/PersistentStorageService.cs
...ore/Desktop/Workspace/Storage/PersistentStorageService.cs
+2
-4
未找到文件。
src/Workspaces/Core/Desktop/Execution/SerializationAnalyzerAssemblyLoader.cs
浏览文件 @
e0d45543
...
...
@@ -39,8 +39,7 @@ protected override Assembly LoadImpl(string fullPath)
private
string
GetAssemblyPath
(
string
fullPath
)
{
string
assemblyPath
;
if
(
_map
.
TryGetValue
(
fullPath
,
out
assemblyPath
))
if
(
_map
.
TryGetValue
(
fullPath
,
out
var
assemblyPath
))
{
return
assemblyPath
;
}
...
...
src/Workspaces/Core/Desktop/SymbolSearch/Patching/Delta.cs
浏览文件 @
e0d45543
...
...
@@ -67,12 +67,10 @@ public static unsafe byte[] ApplyPatch(byte[] sourceBytes, byte[] patchBytes)
{
DeltaInput
ds
=
new
DeltaInput
(
pSourceBuf
,
sourceBytes
.
Length
,
true
);
DeltaInput
dp
=
new
DeltaInput
(
pPatchBuf
,
patchBytes
.
Length
,
true
);
DeltaOutput
output
;
if
(!
ApplyDeltaB
(
DeltaApplyFlag
.
None
,
ds
,
dp
,
out
output
))
out
var
output
))
{
throw
new
Win32Exception
();
}
...
...
src/Workspaces/Core/Desktop/SymbolSearch/SymbolSearchUpdateEngine.Update.cs
浏览文件 @
e0d45543
...
...
@@ -410,9 +410,7 @@ private async Task<TimeSpan> ProcessPatchXElementAsync(XElement patchElement, by
private
async
Task
<
TimeSpan
?>
TryProcessPatchXElementAsync
(
XElement
patchElement
,
byte
[]
databaseBytes
)
{
bool
upToDate
,
tooOld
;
byte
[]
patchBytes
;
ParsePatchElement
(
patchElement
,
out
upToDate
,
out
tooOld
,
out
patchBytes
);
ParsePatchElement
(
patchElement
,
out
var
upToDate
,
out
var
tooOld
,
out
var
patchBytes
);
if
(
upToDate
)
{
...
...
src/Workspaces/Core/Desktop/SymbolSearch/SymbolSearchUpdateEngine.cs
浏览文件 @
e0d45543
...
...
@@ -74,8 +74,7 @@ public SymbolSearchUpdateEngine(ISymbolSearchLogService logService)
public
Task
<
ImmutableArray
<
PackageWithTypeResult
>>
FindPackagesWithTypeAsync
(
string
source
,
string
name
,
int
arity
)
{
IAddReferenceDatabaseWrapper
databaseWrapper
;
if
(!
_sourceToDatabase
.
TryGetValue
(
source
,
out
databaseWrapper
))
if
(!
_sourceToDatabase
.
TryGetValue
(
source
,
out
var
databaseWrapper
))
{
// Don't have a database to search.
return
SpecializedTasks
.
EmptyImmutableArray
<
PackageWithTypeResult
>();
...
...
@@ -112,8 +111,7 @@ public SymbolSearchUpdateEngine(ISymbolSearchLogService logService)
public
Task
<
ImmutableArray
<
PackageWithAssemblyResult
>>
FindPackagesWithAssemblyAsync
(
string
source
,
string
assemblyName
)
{
IAddReferenceDatabaseWrapper
databaseWrapper
;
if
(!
_sourceToDatabase
.
TryGetValue
(
source
,
out
databaseWrapper
))
if
(!
_sourceToDatabase
.
TryGetValue
(
source
,
out
var
databaseWrapper
))
{
// Don't have a database to search.
return
SpecializedTasks
.
EmptyImmutableArray
<
PackageWithAssemblyResult
>();
...
...
@@ -124,12 +122,8 @@ public SymbolSearchUpdateEngine(ISymbolSearchLogService logService)
var
database
=
databaseWrapper
.
Database
;
var
index
=
database
.
Index
;
var
stringStore
=
database
.
StringStore
;
Range
range
;
int
[]
matches
;
int
startIndex
,
count
;
if
(
stringStore
.
TryFindString
(
assemblyName
,
out
range
)
&&
index
.
TryGetMatchesInRange
(
range
,
out
matches
,
out
startIndex
,
out
count
))
if
(
stringStore
.
TryFindString
(
assemblyName
,
out
var
range
)
&&
index
.
TryGetMatchesInRange
(
range
,
out
var
matches
,
out
var
startIndex
,
out
var
count
))
{
for
(
var
i
=
startIndex
;
i
<
(
startIndex
+
count
);
i
++)
{
...
...
@@ -152,8 +146,7 @@ public SymbolSearchUpdateEngine(ISymbolSearchLogService logService)
string
name
,
int
arity
)
{
// Our reference assembly data is stored in the nuget.org DB.
IAddReferenceDatabaseWrapper
databaseWrapper
;
if
(!
_sourceToDatabase
.
TryGetValue
(
NugetOrgSource
,
out
databaseWrapper
))
if
(!
_sourceToDatabase
.
TryGetValue
(
NugetOrgSource
,
out
var
databaseWrapper
))
{
// Don't have a database to search.
return
SpecializedTasks
.
EmptyImmutableArray
<
ReferenceAssemblyWithTypeResult
>();
...
...
@@ -221,10 +214,8 @@ private PackageWithTypeResult CreateResult(AddReferenceDatabase database, Symbol
private
int
GetRank
(
Symbol
symbol
)
{
Symbol
rankingSymbol
;
int
rank
;
if
(!
TryGetRankingSymbol
(
symbol
,
out
rankingSymbol
)
||
!
int
.
TryParse
(
rankingSymbol
.
Name
.
ToString
(),
out
rank
))
if
(!
TryGetRankingSymbol
(
symbol
,
out
var
rankingSymbol
)
||
!
int
.
TryParse
(
rankingSymbol
.
Name
.
ToString
(),
out
var
rank
))
{
return
0
;
}
...
...
src/Workspaces/Core/Desktop/Workspace/Esent/EsentPersistentStorage.cs
浏览文件 @
e0d45543
...
...
@@ -80,10 +80,8 @@ public override Task<Stream> ReadStreamAsync(Document document, string name, Can
return
SpecializedTasks
.
Default
<
Stream
>();
}
int
nameId
;
EsentStorage
.
Key
key
;
if
(!
TryGetProjectAndDocumentKey
(
document
,
out
key
)
||
!
TryGetUniqueNameId
(
name
,
out
nameId
))
if
(!
TryGetProjectAndDocumentKey
(
document
,
out
var
key
)
||
!
TryGetUniqueNameId
(
name
,
out
var
nameId
))
{
return
SpecializedTasks
.
Default
<
Stream
>();
}
...
...
@@ -101,10 +99,8 @@ public override Task<Stream> ReadStreamAsync(Project project, string name, Cance
return
SpecializedTasks
.
Default
<
Stream
>();
}
int
nameId
;
EsentStorage
.
Key
key
;
if
(!
TryGetProjectKey
(
project
,
out
key
)
||
!
TryGetUniqueNameId
(
name
,
out
nameId
))
if
(!
TryGetProjectKey
(
project
,
out
var
key
)
||
!
TryGetUniqueNameId
(
name
,
out
var
nameId
))
{
return
SpecializedTasks
.
Default
<
Stream
>();
}
...
...
@@ -122,8 +118,7 @@ public override Task<Stream> ReadStreamAsync(string name, CancellationToken canc
return
SpecializedTasks
.
Default
<
Stream
>();
}
int
nameId
;
if
(!
TryGetUniqueNameId
(
name
,
out
nameId
))
if
(!
TryGetUniqueNameId
(
name
,
out
var
nameId
))
{
return
SpecializedTasks
.
Default
<
Stream
>();
}
...
...
@@ -172,10 +167,8 @@ public override Task<bool> WriteStreamAsync(Document document, string name, Stre
return
SpecializedTasks
.
False
;
}
int
nameId
;
EsentStorage
.
Key
key
;
if
(!
TryGetProjectAndDocumentKey
(
document
,
out
key
)
||
!
TryGetUniqueNameId
(
name
,
out
nameId
))
if
(!
TryGetProjectAndDocumentKey
(
document
,
out
var
key
)
||
!
TryGetUniqueNameId
(
name
,
out
var
nameId
))
{
return
SpecializedTasks
.
False
;
}
...
...
@@ -194,10 +187,8 @@ public override Task<bool> WriteStreamAsync(Project project, string name, Stream
return
SpecializedTasks
.
False
;
}
int
nameId
;
EsentStorage
.
Key
key
;
if
(!
TryGetProjectKey
(
project
,
out
key
)
||
!
TryGetUniqueNameId
(
name
,
out
nameId
))
if
(!
TryGetProjectKey
(
project
,
out
var
key
)
||
!
TryGetUniqueNameId
(
name
,
out
var
nameId
))
{
return
SpecializedTasks
.
False
;
}
...
...
@@ -216,8 +207,7 @@ public override Task<bool> WriteStreamAsync(string name, Stream stream, Cancella
return
SpecializedTasks
.
False
;
}
int
nameId
;
if
(!
TryGetUniqueNameId
(
name
,
out
nameId
))
if
(!
TryGetUniqueNameId
(
name
,
out
var
nameId
))
{
return
SpecializedTasks
.
False
;
}
...
...
@@ -337,12 +327,8 @@ private EsentStorage.ProjectDocumentTableAccessor GetAccessor(EsentStorage.Key k
private
bool
TryGetProjectAndDocumentKey
(
Document
document
,
out
EsentStorage
.
Key
key
)
{
key
=
default
(
EsentStorage
.
Key
);
int
projectId
;
int
projectNameId
;
int
documentId
;
if
(!
TryGetProjectId
(
document
.
Project
,
out
projectId
,
out
projectNameId
)
||
!
TryGetUniqueFileId
(
document
.
FilePath
,
out
documentId
))
if
(!
TryGetProjectId
(
document
.
Project
,
out
var
projectId
,
out
var
projectNameId
)
||
!
TryGetUniqueFileId
(
document
.
FilePath
,
out
var
documentId
))
{
return
false
;
}
...
...
@@ -354,10 +340,7 @@ private bool TryGetProjectAndDocumentKey(Document document, out EsentStorage.Key
private
bool
TryGetProjectKey
(
Project
project
,
out
EsentStorage
.
Key
key
)
{
key
=
default
(
EsentStorage
.
Key
);
int
projectId
;
int
projectNameId
;
if
(!
TryGetProjectId
(
project
,
out
projectId
,
out
projectNameId
))
if
(!
TryGetProjectId
(
project
,
out
var
projectId
,
out
var
projectNameId
))
{
return
false
;
}
...
...
src/Workspaces/Core/Desktop/Workspace/Esent/EsentPersistentStorage_IdentifierTable.cs
浏览文件 @
e0d45543
...
...
@@ -65,8 +65,7 @@ private VersionStamp GetIdentifierSetVersion(EsentStorage.Key key)
return
VersionStamp
.
Default
;
}
int
identifierId
;
if
(!
TryGetIdentifierSetVersionId
(
out
identifierId
))
if
(!
TryGetIdentifierSetVersionId
(
out
var
identifierId
))
{
return
VersionStamp
.
Default
;
}
...
...
@@ -99,8 +98,7 @@ public VersionStamp GetIdentifierSetVersion(Document document)
return
VersionStamp
.
Default
;
}
EsentStorage
.
Key
key
;
if
(!
TryGetProjectAndDocumentKey
(
document
,
out
key
))
if
(!
TryGetProjectAndDocumentKey
(
document
,
out
var
key
))
{
return
VersionStamp
.
Default
;
}
...
...
@@ -117,9 +115,7 @@ public bool ReadIdentifierPositions(Document document, VersionStamp syntaxVersio
return
false
;
}
int
identifierId
;
EsentStorage
.
Key
key
;
if
(!
TryGetProjectAndDocumentKey
(
document
,
out
key
))
if
(!
TryGetProjectAndDocumentKey
(
document
,
out
var
key
))
{
return
false
;
}
...
...
@@ -130,7 +126,7 @@ public bool ReadIdentifierPositions(Document document, VersionStamp syntaxVersio
return
false
;
}
if
(!
TryGetUniqueIdentifierId
(
identifier
,
out
identifierId
))
if
(!
TryGetUniqueIdentifierId
(
identifier
,
out
var
identifierId
))
{
return
false
;
}
...
...
@@ -180,8 +176,7 @@ public bool WriteIdentifierLocations(Document document, VersionStamp version, Sy
return
false
;
}
EsentStorage
.
Key
key
;
if
(!
TryGetProjectAndDocumentKey
(
document
,
out
key
))
if
(!
TryGetProjectAndDocumentKey
(
document
,
out
var
key
))
{
return
false
;
}
...
...
@@ -290,8 +285,7 @@ private void Free(Dictionary<string, List<int>> map)
private
bool
TrySaveIdentifierSetVersion
(
EsentStorage
.
IdentifierLocationTableAccessor
accessor
,
EsentStorage
.
Key
key
,
VersionStamp
version
)
{
int
identifierId
;
if
(!
TryGetIdentifierSetVersionId
(
out
identifierId
))
if
(!
TryGetIdentifierSetVersionId
(
out
var
identifierId
))
{
return
false
;
}
...
...
src/Workspaces/Core/Desktop/Workspace/Esent/EsentStorage.OpenSession.cs
浏览文件 @
e0d45543
...
...
@@ -73,8 +73,7 @@ public void Close()
private
JET_DBID
OpenExistingDatabase
(
JET_SESID
session
,
string
databaseFile
)
{
JET_DBID
databaseId
;
Api
.
JetOpenDatabase
(
SessionId
,
databaseFile
,
null
,
out
databaseId
,
OpenDatabaseGrbit
.
None
);
Api
.
JetOpenDatabase
(
SessionId
,
databaseFile
,
null
,
out
var
databaseId
,
OpenDatabaseGrbit
.
None
);
return
databaseId
;
}
...
...
src/Workspaces/Core/Desktop/Workspace/Esent/EsentStorage.cs
浏览文件 @
e0d45543
...
...
@@ -144,8 +144,7 @@ private AbstractTableAccessor GetTableAccessor(TableKinds tableKind)
private
OpenSession
GetOpenSession
()
{
OpenSession
session
;
if
(
_sessionCache
.
TryPop
(
out
session
))
if
(
_sessionCache
.
TryPop
(
out
var
session
))
{
return
session
;
}
...
...
@@ -223,9 +222,7 @@ private Instance CreateEsentInstance()
private
void
TryInitializeGlobalParameters
()
{
int
instances
;
JET_INSTANCE_INFO
[]
infos
;
Api
.
JetGetInstanceInfo
(
out
instances
,
out
infos
);
Api
.
JetGetInstanceInfo
(
out
var
instances
,
out
var
infos
);
// already initialized nothing we can do.
if
(
instances
!=
0
)
...
...
src/Workspaces/Core/Desktop/Workspace/Host/Documentation/DocumentationProviderServiceFactory.cs
浏览文件 @
e0d45543
...
...
@@ -30,9 +30,7 @@ public DocumentationProvider GetDocumentationProvider(string assemblyPath)
}
assemblyPath
=
Path
.
ChangeExtension
(
assemblyPath
,
"xml"
);
DocumentationProvider
provider
;
if
(!
_assemblyPathToDocumentationProviderMap
.
TryGetValue
(
assemblyPath
,
out
provider
))
if
(!
_assemblyPathToDocumentationProviderMap
.
TryGetValue
(
assemblyPath
,
out
var
provider
))
{
provider
=
_assemblyPathToDocumentationProviderMap
.
GetOrAdd
(
assemblyPath
,
_path
=>
XmlDocumentationProvider
.
CreateFromFile
(
_path
));
}
...
...
src/Workspaces/Core/Desktop/Workspace/Host/Mef/MefV1HostServices.cs
浏览文件 @
e0d45543
...
...
@@ -64,9 +64,8 @@ protected internal override HostWorkspaceServices CreateWorkspaceServices(Worksp
/// </summary>
public
IEnumerable
<
Lazy
<
TExtension
,
TMetadata
>>
GetExports
<
TExtension
,
TMetadata
>()
{
IEnumerable
exports
;
var
key
=
new
ExportKey
(
typeof
(
TExtension
).
AssemblyQualifiedName
,
typeof
(
TMetadata
).
AssemblyQualifiedName
);
if
(!
_exportsMap
.
TryGetValue
(
key
,
out
exports
))
if
(!
_exportsMap
.
TryGetValue
(
key
,
out
var
exports
))
{
exports
=
ImmutableInterlocked
.
GetOrAdd
(
ref
_exportsMap
,
key
,
_
=>
{
...
...
@@ -82,9 +81,8 @@ protected internal override HostWorkspaceServices CreateWorkspaceServices(Worksp
/// </summary>
public
IEnumerable
<
Lazy
<
TExtension
>>
GetExports
<
TExtension
>()
{
IEnumerable
exports
;
var
key
=
new
ExportKey
(
typeof
(
TExtension
).
AssemblyQualifiedName
,
""
);
if
(!
_exportsMap
.
TryGetValue
(
key
,
out
exports
))
if
(!
_exportsMap
.
TryGetValue
(
key
,
out
var
exports
))
{
exports
=
ImmutableInterlocked
.
GetOrAdd
(
ref
_exportsMap
,
key
,
_
=>
_exportProvider
.
GetExports
<
TExtension
>().
ToImmutableArray
());
...
...
src/Workspaces/Core/Desktop/Workspace/MSBuild/CSharp/CSharpProjectFileLoader.CSharpProjectFile.cs
浏览文件 @
e0d45543
...
...
@@ -181,10 +181,7 @@ private void InitializeFromModel(CSharpCompilerInputs compilerInputs, MSB.Execut
compilerInputs
.
SetAnalyzers
(
this
.
GetAnalyzerReferencesFromModel
(
executedProject
).
ToArray
());
compilerInputs
.
SetAdditionalFiles
(
this
.
GetAdditionalFilesFromModel
(
executedProject
).
ToArray
());
compilerInputs
.
SetSources
(
this
.
GetDocumentsFromModel
(
executedProject
).
ToArray
());
string
errorMessage
;
int
errorCode
;
compilerInputs
.
EndInitialization
(
out
errorMessage
,
out
errorCode
);
compilerInputs
.
EndInitialization
(
out
var
errorMessage
,
out
var
errorCode
);
}
private
class
CSharpCompilerInputs
:
...
...
src/Workspaces/Core/Desktop/Workspace/MSBuild/MSBuildProjectLoader.cs
浏览文件 @
e0d45543
...
...
@@ -152,8 +152,7 @@ private void SetSolutionProperties(string solutionFilePath)
var
projectAbsolutePath
=
TryGetAbsolutePath
(
project
.
AbsolutePath
,
reportMode
);
if
(
projectAbsolutePath
!=
null
)
{
IProjectFileLoader
loader
;
if
(
TryGetLoaderFromProjectPath
(
projectAbsolutePath
,
reportMode
,
out
loader
))
if
(
TryGetLoaderFromProjectPath
(
projectAbsolutePath
,
reportMode
,
out
var
loader
))
{
// projects get added to 'loadedProjects' as side-effect
// never prefer metadata when loading solution, all projects get loaded if they can.
...
...
@@ -202,11 +201,8 @@ internal string GetAbsoluteSolutionPath(string path, string baseDirectory)
throw
new
ArgumentNullException
(
nameof
(
projectFilePath
));
}
string
fullPath
;
this
.
TryGetAbsoluteProjectPath
(
projectFilePath
,
Directory
.
GetCurrentDirectory
(),
ReportMode
.
Throw
,
out
fullPath
);
IProjectFileLoader
loader
;
this
.
TryGetLoaderFromProjectPath
(
projectFilePath
,
ReportMode
.
Throw
,
out
loader
);
this
.
TryGetAbsoluteProjectPath
(
projectFilePath
,
Directory
.
GetCurrentDirectory
(),
ReportMode
.
Throw
,
out
var
fullPath
);
this
.
TryGetLoaderFromProjectPath
(
projectFilePath
,
ReportMode
.
Throw
,
out
var
loader
);
var
loadedProjects
=
new
LoadState
(
projectPathToProjectIdMap
);
var
id
=
await
this
.
LoadProjectAsync
(
fullPath
,
loader
,
this
.
LoadMetadataForReferencedProjects
,
loadedProjects
,
cancellationToken
).
ConfigureAwait
(
false
);
...
...
@@ -253,21 +249,16 @@ public void Add(ProjectInfo info)
/// </summary>
public
bool
ProjectAlreadyReferencesProject
(
ProjectId
fromProject
,
ProjectId
targetProject
)
{
Dictionary
<
ProjectId
,
bool
>
fromProjectMemo
;
if
(
!
_projectAlreadyReferencesProjectResultCache
.
TryGetValue
(
fromProject
,
out
fromProjectMemo
))
if
(
!
_projectAlreadyReferencesProjectResultCache
.
TryGetValue
(
fromProject
,
out
var
fromProjectMemo
))
{
fromProjectMemo
=
new
Dictionary
<
ProjectId
,
bool
>();
_projectAlreadyReferencesProjectResultCache
.
Add
(
fromProject
,
fromProjectMemo
);
}
bool
answer
;
if
(
!
fromProjectMemo
.
TryGetValue
(
targetProject
,
out
answer
))
if
(
!
fromProjectMemo
.
TryGetValue
(
targetProject
,
out
var
answer
))
{
ProjectInfo
info
;
answer
=
_projectIdToProjectInfoMap
.
TryGetValue
(
fromProject
,
out
info
)
&&
_projectIdToProjectInfoMap
.
TryGetValue
(
fromProject
,
out
var
info
)
&&
info
.
ProjectReferences
.
Any
(
pr
=>
pr
.
ProjectId
==
targetProject
||
ProjectAlreadyReferencesProject
(
pr
.
ProjectId
,
targetProject
)
...
...
@@ -285,15 +276,13 @@ public IEnumerable<ProjectInfo> Projects
public
ProjectId
GetProjectId
(
string
fullProjectPath
)
{
ProjectId
id
;
_projectPathToProjectIdMap
.
TryGetValue
(
fullProjectPath
,
out
id
);
_projectPathToProjectIdMap
.
TryGetValue
(
fullProjectPath
,
out
var
id
);
return
id
;
}
public
ProjectId
GetOrCreateProjectId
(
string
fullProjectPath
)
{
ProjectId
id
;
if
(!
_projectPathToProjectIdMap
.
TryGetValue
(
fullProjectPath
,
out
id
))
if
(!
_projectPathToProjectIdMap
.
TryGetValue
(
fullProjectPath
,
out
var
id
))
{
id
=
ProjectId
.
CreateNewId
(
debugName
:
fullProjectPath
);
_projectPathToProjectIdMap
.
Add
(
fullProjectPath
,
id
);
...
...
@@ -376,9 +365,7 @@ 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
);
GetDocumentNameAndFolders
(
docFileInfo
.
LogicalPath
,
out
var
name
,
out
var
folders
);
docs
.
Add
(
DocumentInfo
.
Create
(
DocumentId
.
CreateNewId
(
projectId
,
debugName
:
docFileInfo
.
FilePath
),
...
...
@@ -393,9 +380,7 @@ private async Task<ProjectId> LoadProjectAsync(string projectFilePath, IProjectF
var
additionalDocs
=
new
List
<
DocumentInfo
>();
foreach
(
var
docFileInfo
in
additionalDocFileInfos
)
{
string
name
;
ImmutableArray
<
string
>
folders
;
GetDocumentNameAndFolders
(
docFileInfo
.
LogicalPath
,
out
name
,
out
folders
);
GetDocumentNameAndFolders
(
docFileInfo
.
LogicalPath
,
out
var
name
,
out
var
folders
);
additionalDocs
.
Add
(
DocumentInfo
.
Create
(
DocumentId
.
CreateNewId
(
projectId
,
debugName
:
docFileInfo
.
FilePath
),
...
...
@@ -523,9 +508,7 @@ private class ResolvedReferences
foreach
(
var
projectFileReference
in
projectFileReferences
)
{
string
fullPath
;
if
(
TryGetAbsoluteProjectPath
(
projectFileReference
.
Path
,
Path
.
GetDirectoryName
(
thisProjectPath
),
reportMode
,
out
fullPath
))
if
(
TryGetAbsoluteProjectPath
(
projectFileReference
.
Path
,
Path
.
GetDirectoryName
(
thisProjectPath
),
reportMode
,
out
var
fullPath
))
{
// if the project is already loaded, then just reference the one we have
var
existingProjectId
=
loadedProjects
.
GetProjectId
(
fullPath
);
...
...
@@ -535,8 +518,7 @@ private class ResolvedReferences
continue
;
}
IProjectFileLoader
loader
;
TryGetLoaderFromProjectPath
(
fullPath
,
ReportMode
.
Ignore
,
out
loader
);
TryGetLoaderFromProjectPath
(
fullPath
,
ReportMode
.
Ignore
,
out
var
loader
);
// get metadata if preferred or if loader is unknown
if
(
preferMetadata
||
loader
==
null
)
...
...
@@ -668,8 +650,7 @@ private bool TryGetLoaderFromProjectPath(string projectFilePath, ReportMode mode
extension
=
extension
.
Substring
(
1
);
}
string
language
;
if
(
_extensionToLanguageMap
.
TryGetValue
(
extension
,
out
language
))
if
(
_extensionToLanguageMap
.
TryGetValue
(
extension
,
out
var
language
))
{
if
(
_workspace
.
Services
.
SupportedLanguages
.
Contains
(
language
))
{
...
...
src/Workspaces/Core/Desktop/Workspace/MSBuild/MSBuildWorkspace.cs
浏览文件 @
e0d45543
...
...
@@ -262,8 +262,7 @@ protected override void ApplyProjectChanges(ProjectChanges projectChanges)
if
(
this
.
HasProjectFileChanges
(
projectChanges
))
{
var
projectPath
=
project
.
FilePath
;
IProjectFileLoader
loader
;
if
(
_loader
.
TryGetLoaderFromProjectPath
(
projectPath
,
out
loader
))
if
(
_loader
.
TryGetLoaderFromProjectPath
(
projectPath
,
out
var
loader
))
{
try
{
...
...
@@ -343,9 +342,7 @@ protected override void ApplyDocumentAdded(DocumentInfo info, SourceText text)
System
.
Diagnostics
.
Debug
.
Assert
(
_applyChangesProjectFile
!=
null
);
var
project
=
this
.
CurrentSolution
.
GetProject
(
info
.
Id
.
ProjectId
);
IProjectFileLoader
loader
;
if
(
_loader
.
TryGetLoaderFromProjectPath
(
project
.
FilePath
,
out
loader
))
if
(
_loader
.
TryGetLoaderFromProjectPath
(
project
.
FilePath
,
out
var
loader
))
{
var
extension
=
_applyChangesProjectFile
.
GetDocumentExtension
(
info
.
SourceCodeKind
);
var
fileName
=
Path
.
ChangeExtension
(
info
.
Name
,
extension
);
...
...
src/Workspaces/Core/Desktop/Workspace/MSBuild/ProjectFile/BuildTargets.cs
浏览文件 @
e0d45543
...
...
@@ -160,8 +160,7 @@ private static IEnumerable<string> SplitTargets(string targets)
private
static
IEnumerable
<
string
>
GetTargetDependents
(
MSB
.
Evaluation
.
Project
project
,
string
targetName
)
{
MSB
.
Execution
.
ProjectTargetInstance
targetInstance
;
if
(
project
.
Targets
.
TryGetValue
(
targetName
,
out
targetInstance
))
if
(
project
.
Targets
.
TryGetValue
(
targetName
,
out
var
targetInstance
))
{
return
SplitTargets
(
project
.
ExpandString
(
targetInstance
.
DependsOnTargets
));
}
...
...
src/Workspaces/Core/Desktop/Workspace/MSBuild/ProjectFile/ProjectFile.cs
浏览文件 @
e0d45543
...
...
@@ -305,8 +305,7 @@ private static int ConvertToInt(string value)
}
else
{
int
result
;
int
.
TryParse
(
value
,
out
result
);
int
.
TryParse
(
value
,
out
var
result
);
return
result
;
}
}
...
...
@@ -329,8 +328,7 @@ private static ulong ConvertToULong(string value)
}
else
{
ulong
result
;
ulong
.
TryParse
(
value
,
out
result
);
ulong
.
TryParse
(
value
,
out
var
result
);
return
result
;
}
}
...
...
@@ -356,8 +354,7 @@ private static ulong ConvertToULong(string value)
}
else
{
TEnum
result
;
if
(
Enum
.
TryParse
<
TEnum
>(
value
,
out
result
))
if
(
Enum
.
TryParse
<
TEnum
>(
value
,
out
var
result
))
{
return
result
;
}
...
...
src/Workspaces/Core/Desktop/Workspace/SolutionSize/SolutionSizeTracker.cs
浏览文件 @
e0d45543
...
...
@@ -86,8 +86,7 @@ public async Task AnalyzeSyntaxAsync(Document document, InvocationReasons reason
return
;
}
long
size
;
if
(
_map
.
TryGetValue
(
document
.
Id
,
out
size
))
if
(
_map
.
TryGetValue
(
document
.
Id
,
out
var
size
))
{
if
(
size
==
length
)
{
...
...
@@ -105,8 +104,7 @@ public async Task AnalyzeSyntaxAsync(Document document, InvocationReasons reason
public
void
RemoveDocument
(
DocumentId
documentId
)
{
long
size
;
if
(
_map
.
TryRemove
(
documentId
,
out
size
))
if
(
_map
.
TryRemove
(
documentId
,
out
var
size
))
{
Interlocked
.
Add
(
ref
_size
,
-
size
);
}
...
...
src/Workspaces/Core/Desktop/Workspace/Storage/PersistentStorageService.cs
浏览文件 @
e0d45543
...
...
@@ -101,8 +101,7 @@ private IPersistentStorage GetStorage(Solution solution, string workingFolderPat
lock
(
_lookupAccessLock
)
{
// see whether we have something we can use
AbstractPersistentStorage
storage
;
if
(
_lookup
.
TryGetValue
(
solution
.
FilePath
,
out
storage
))
if
(
_lookup
.
TryGetValue
(
solution
.
FilePath
,
out
var
storage
))
{
// previous attempt to create esent storage failed.
if
(
storage
==
null
&&
!
SolutionSizeAboveThreshold
(
solution
))
...
...
@@ -202,8 +201,7 @@ private string GetWorkingFolderPath(Solution solution)
private
AbstractPersistentStorage
TryCreateEsentStorage
(
string
workingFolderPath
,
string
solutionPath
)
{
AbstractPersistentStorage
esentStorage
;
if
(
TryCreateEsentStorage
(
workingFolderPath
,
solutionPath
,
out
esentStorage
))
if
(
TryCreateEsentStorage
(
workingFolderPath
,
solutionPath
,
out
var
esentStorage
))
{
return
esentStorage
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录