Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
a149a9a0
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,发现更多精彩内容 >>
提交
a149a9a0
编写于
3月 18, 2020
作者:
C
Cyrus Najmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
NRT
上级
a04d1d80
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
23 addition
and
17 deletion
+23
-17
src/Workspaces/Core/Portable/Storage/AbstractPersistentStorageService.cs
...Core/Portable/Storage/AbstractPersistentStorageService.cs
+8
-6
src/Workspaces/Core/Portable/Storage/PersistenceStorageServiceFactory.cs
...Core/Portable/Storage/PersistenceStorageServiceFactory.cs
+1
-3
src/Workspaces/Core/Portable/Storage/SQLite/SQLitePersistentStorageService.cs
...Portable/Storage/SQLite/SQLitePersistentStorageService.cs
+14
-8
未找到文件。
src/Workspaces/Core/Portable/Storage/AbstractPersistentStorageService.cs
浏览文件 @
a149a9a0
...
...
@@ -27,8 +27,8 @@ internal abstract partial class AbstractPersistentStorageService : IChecksummedP
/// This lock guards all mutable fields in this type.
/// </summary>
private
readonly
object
_lock
=
new
object
();
private
ReferenceCountedDisposable
<
IChecksummedPersistentStorage
>
_currentPersistentStorage
;
private
SolutionId
_currentPersistentStorageSolutionId
;
private
ReferenceCountedDisposable
<
IChecksummedPersistentStorage
>
?
_currentPersistentStorage
;
private
SolutionId
?
_currentPersistentStorageSolutionId
;
protected
AbstractPersistentStorageService
(
IPersistentStorageLocationService
locationService
)
=>
_locationService
=
locationService
;
...
...
@@ -71,7 +71,7 @@ internal IChecksummedPersistentStorage GetStorageWorker(Solution solution)
{
// We do, great. Increment our ref count for our caller. They'll decrement it
// when done with it.
return
PersistentStorageReferenceCountedDisposableWrapper
.
AddReferenceCountToAndCreateWrapper
(
_currentPersistentStorage
);
return
PersistentStorageReferenceCountedDisposableWrapper
.
AddReferenceCountToAndCreateWrapper
(
_currentPersistentStorage
!
);
}
var
workingFolder
=
_locationService
.
TryGetStorageLocation
(
solution
);
...
...
@@ -144,7 +144,7 @@ private IChecksummedPersistentStorage CreatePersistentStorage(Solution solution,
var
databaseFilePath
=
GetDatabaseFilePath
(
workingFolderPath
);
try
{
return
TryOpenDatabase
(
solution
,
workingFolderPath
,
databaseFilePath
)
return
TryOpenDatabase
(
solution
,
workingFolderPath
,
databaseFilePath
)
;
}
catch
(
Exception
ex
)
{
...
...
@@ -164,7 +164,7 @@ private IChecksummedPersistentStorage CreatePersistentStorage(Solution solution,
private
void
Shutdown
()
{
ReferenceCountedDisposable
<
IChecksummedPersistentStorage
>
storage
=
null
;
ReferenceCountedDisposable
<
IChecksummedPersistentStorage
>
?
storage
=
null
;
lock
(
_lock
)
{
...
...
@@ -211,7 +211,9 @@ private PersistentStorageReferenceCountedDisposableWrapper(ReferenceCountedDispo
public
static
IChecksummedPersistentStorage
AddReferenceCountToAndCreateWrapper
(
ReferenceCountedDisposable
<
IChecksummedPersistentStorage
>
storage
)
{
return
new
PersistentStorageReferenceCountedDisposableWrapper
(
storage
.
TryAddReference
());
// This should only be called from a caller that has a non-null storage that it
// already has a reference on. So .TryAddReference cannot fail.
return
new
PersistentStorageReferenceCountedDisposableWrapper
(
storage
.
TryAddReference
()
??
throw
new
InvalidOperationException
());
}
public
void
Dispose
()
...
...
src/Workspaces/Core/Portable/Storage/PersistenceStorageServiceFactory.cs
浏览文件 @
a149a9a0
...
...
@@ -32,9 +32,7 @@ public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices)
case
StorageDatabase
.
SQLite
:
var
locationService
=
workspaceServices
.
GetService
<
IPersistentStorageLocationService
>();
if
(
locationService
!=
null
)
{
return
new
SQLitePersistentStorageService
(
optionService
,
locationService
);
}
return
new
SQLitePersistentStorageService
(
locationService
);
break
;
}
...
...
src/Workspaces/Core/Portable/Storage/SQLite/SQLitePersistentStorageService.cs
浏览文件 @
a149a9a0
...
...
@@ -2,11 +2,12 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System
;
using
System.IO
;
using
System.Runtime.InteropServices
;
using
Microsoft.CodeAnalysis.Host
;
using
Microsoft.CodeAnalysis.Options
;
using
Microsoft.CodeAnalysis.Shared.Utilities
;
using
Microsoft.CodeAnalysis.Storage
;
using
Roslyn.Utilities
;
...
...
@@ -19,7 +20,7 @@ internal partial class SQLitePersistentStorageService : AbstractPersistentStorag
private
const
string
StorageExtension
=
"sqlite3"
;
private
const
string
PersistentStorageFileName
=
"storage.ide"
;
private
readonly
IPersistentStorageFaultInjector
_faultInjectorOpt
;
private
readonly
IPersistentStorageFaultInjector
?
_faultInjectorOpt
;
[
DllImport
(
"kernel32.dll"
)]
private
static
extern
IntPtr
LoadLibrary
(
string
dllToLoad
);
...
...
@@ -41,6 +42,8 @@ private static bool TryInitializeLibrariesLazy()
{
var
myFolder
=
Path
.
GetDirectoryName
(
typeof
(
SQLitePersistentStorage
).
Assembly
.
Location
);
if
(
myFolder
==
null
)
return
false
;
var
is64
=
IntPtr
.
Size
==
8
;
var
subfolder
=
is64
?
"x64"
:
"x86"
;
...
...
@@ -68,10 +71,9 @@ public SQLitePersistentStorageService(IPersistentStorageLocationService location
}
public
SQLitePersistentStorageService
(
IOptionService
optionService
,
IPersistentStorageLocationService
locationService
,
IPersistentStorageFaultInjector
faultInjector
)
:
this
(
optionService
,
locationService
)
:
this
(
locationService
)
{
_faultInjectorOpt
=
faultInjector
;
}
...
...
@@ -98,7 +100,7 @@ protected override string GetDatabaseFilePath(string workingFolderPath)
return
null
;
}
SQLitePersistentStorage
sqlStorage
=
null
;
SQLitePersistentStorage
?
sqlStorage
=
null
;
try
{
sqlStorage
=
new
SQLitePersistentStorage
(
...
...
@@ -125,15 +127,19 @@ protected override string GetDatabaseFilePath(string workingFolderPath)
}
}
private
static
IDisposable
TryGetDatabaseOwnership
(
string
databaseFilePath
)
private
static
IDisposable
?
TryGetDatabaseOwnership
(
string
databaseFilePath
)
{
return
IOUtilities
.
PerformIO
<
IDisposable
>(()
=>
return
IOUtilities
.
PerformIO
<
IDisposable
?
>(()
=>
{
// make sure directory exist first.
EnsureDirectory
(
databaseFilePath
);
var
directoryName
=
Path
.
GetDirectoryName
(
databaseFilePath
);
if
(
directoryName
==
null
)
return
null
;
return
File
.
Open
(
Path
.
Combine
(
Path
.
GetDirectoryName
(
databaseFilePath
)
,
LockFile
),
Path
.
Combine
(
directoryName
,
LockFile
),
FileMode
.
OpenOrCreate
,
FileAccess
.
ReadWrite
,
FileShare
.
None
);
});
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录