Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
7698b09e
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,发现更多精彩内容 >>
提交
7698b09e
编写于
4月 16, 2020
作者:
S
Sam Harwell
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use DisposableDirectory for resources in AbstractPersistentStorageTests
上级
e648eee0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
17 addition
and
24 deletion
+17
-24
src/VisualStudio/CSharp/Test/PersistentStorage/AbstractPersistentStorageTests.cs
.../Test/PersistentStorage/AbstractPersistentStorageTests.cs
+17
-24
未找到文件。
src/VisualStudio/CSharp/Test/PersistentStorage/AbstractPersistentStorageTests.cs
浏览文件 @
7698b09e
...
...
@@ -10,11 +10,8 @@
using
System.Threading
;
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis.Host
;
using
Microsoft.CodeAnalysis.Options
;
using
Microsoft.CodeAnalysis.SQLite
;
using
Microsoft.CodeAnalysis.Storage
;
using
Microsoft.CodeAnalysis.Test.Utilities
;
using
Moq
;
using
Xunit
;
namespace
Microsoft.CodeAnalysis.UnitTests.WorkspaceServices
...
...
@@ -35,7 +32,8 @@ public enum Size
private
readonly
Encoding
_encoding
=
Encoding
.
UTF8
;
private
AbstractPersistentStorageService
_storageService
;
private
readonly
string
_persistentFolder
;
private
readonly
DisposableDirectory
_persistentFolderRoot
;
private
readonly
TempDirectory
_persistentFolder
;
private
const
int
LargeSize
=
(
int
)(
SQLite
.
v2
.
SQLitePersistentStorage
.
MaxPooledByteArrayLength
*
2
);
private
const
int
MediumSize
=
(
int
)(
SQLite
.
v2
.
SQLitePersistentStorage
.
MaxPooledByteArrayLength
/
2
);
...
...
@@ -65,8 +63,8 @@ static AbstractPersistentStorageTests()
protected
AbstractPersistentStorageTests
()
{
_persistentFolder
=
Path
.
Combine
(
Path
.
GetTempPath
(),
PersistentFolderPrefix
+
Guid
.
NewGuid
());
Directory
.
CreateDirectory
(
_persistentFolder
);
_persistentFolder
Root
=
new
DisposableDirectory
(
new
TempRoot
());
_persistentFolder
=
_persistentFolderRoot
.
CreateDirectory
(
PersistentFolderPrefix
+
Guid
.
NewGuid
()
);
ThreadPool
.
GetMinThreads
(
out
var
workerThreads
,
out
var
completionPortThreads
);
ThreadPool
.
SetMinThreads
(
Math
.
Max
(
workerThreads
,
NumThreads
),
completionPortThreads
);
...
...
@@ -76,11 +74,7 @@ public void Dispose()
{
// This should cause the service to release the cached connection it maintains for the primary workspace
_storageService
?.
GetTestAccessor
().
Shutdown
();
if
(
Directory
.
Exists
(
_persistentFolder
))
{
Directory
.
Delete
(
_persistentFolder
,
true
);
}
_persistentFolderRoot
.
Dispose
();
}
private
string
GetData1
(
Size
size
)
...
...
@@ -158,7 +152,7 @@ public async Task PersistentService_Solution_WriteReadReopenSolution(Size size,
[
Theory
]
[
CombinatorialData
]
p
rivate
async
Task
PersistentService_Solution_WriteReadSameInstance
(
Size
size
,
bool
withChecksum
)
p
ublic
async
Task
PersistentService_Solution_WriteReadSameInstance
(
Size
size
,
bool
withChecksum
)
{
var
solution
=
CreateOrOpenSolution
();
var
streamName1
=
"PersistentService_Solution_WriteReadSameInstance1"
;
...
...
@@ -172,7 +166,7 @@ private async Task PersistentService_Solution_WriteReadSameInstance(Size size, b
Assert
.
Equal
(
GetData2
(
size
),
ReadStringToEnd
(
await
storage
.
ReadStreamAsync
(
streamName2
,
GetChecksum2
(
withChecksum
))));
}
[
Theory
(
Skip
=
"https://github.com/dotnet/roslyn/issues/22437"
)
]
[
Theory
]
[
CombinatorialData
]
public
async
Task
PersistentService_Project_WriteReadSameInstance
(
Size
size
,
bool
withChecksum
)
{
...
...
@@ -294,8 +288,10 @@ public async Task PersistentService_Project_SimultaneousReads(Size size, bool wi
[
Theory
]
[
CombinatorialData
]
public
async
Task
PersistentService_Document_SimultaneousReads
(
Size
size
,
bool
withChecksum
)
public
async
Task
PersistentService_Document_SimultaneousReads
(
Size
size
,
bool
withChecksum
,
[
CombinatorialRange
(
0
,
100
)]
int
iteration
)
{
_
=
iteration
;
var
solution
=
CreateOrOpenSolution
();
var
streamName1
=
"PersistentService_Document_SimultaneousReads1"
;
...
...
@@ -477,26 +473,23 @@ private void DoSimultaneousReads(Func<Task<string>> read, string expectedValue)
protected
Solution
CreateOrOpenSolution
(
bool
nullPaths
=
false
)
{
var
solutionFile
=
Path
.
Combine
(
_persistentFolder
,
"Solution1.sln"
);
File
.
WriteAllText
(
solutionFile
,
""
);
var
solutionFile
=
_persistentFolder
.
CreateOrOpenFile
(
"Solution1.sln"
).
WriteAllText
(
""
);
var
info
=
SolutionInfo
.
Create
(
SolutionId
.
CreateNewId
(),
VersionStamp
.
Create
(),
solutionFile
);
var
info
=
SolutionInfo
.
Create
(
SolutionId
.
CreateNewId
(),
VersionStamp
.
Create
(),
solutionFile
.
Path
);
var
workspace
=
new
AdhocWorkspace
();
workspace
.
AddSolution
(
info
);
var
solution
=
workspace
.
CurrentSolution
;
var
projectFile
=
Path
.
Combine
(
Path
.
GetDirectoryName
(
solutionFile
),
"Project1.csproj"
);
File
.
WriteAllText
(
projectFile
,
""
);
var
projectFile
=
_persistentFolder
.
CreateOrOpenFile
(
"Project1.csproj"
).
WriteAllText
(
""
);
solution
=
solution
.
AddProject
(
ProjectInfo
.
Create
(
ProjectId
.
CreateNewId
(),
VersionStamp
.
Create
(),
"Project1"
,
"Project1"
,
LanguageNames
.
CSharp
,
filePath
:
nullPaths
?
null
:
projectFile
));
filePath
:
nullPaths
?
null
:
projectFile
.
Path
));
var
project
=
solution
.
Projects
.
Single
();
var
documentFile
=
Path
.
Combine
(
Path
.
GetDirectoryName
(
projectFile
),
"Document1.cs"
);
File
.
WriteAllText
(
documentFile
,
""
);
var
documentFile
=
_persistentFolder
.
CreateOrOpenFile
(
"Document1.cs"
).
WriteAllText
(
""
);
solution
=
solution
.
AddDocument
(
DocumentInfo
.
Create
(
DocumentId
.
CreateNewId
(
project
.
Id
),
"Document1"
,
filePath
:
nullPaths
?
null
:
documentFile
));
filePath
:
nullPaths
?
null
:
documentFile
.
Path
));
// Apply this to the workspace so our Solution is the primary branch ID, which matches our usual behavior
workspace
.
TryApplyChanges
(
solution
);
...
...
@@ -509,7 +502,7 @@ protected Solution CreateOrOpenSolution(bool nullPaths = false)
{
// If we handed out one for a previous test, we need to shut that down first
_storageService
?.
GetTestAccessor
().
Shutdown
();
var
locationService
=
new
MockPersistentStorageLocationService
(
solution
.
Id
,
_persistentFolder
);
var
locationService
=
new
MockPersistentStorageLocationService
(
solution
.
Id
,
_persistentFolder
.
Path
);
_storageService
=
GetStorageService
(
locationService
,
faultInjectorOpt
);
var
storage
=
_storageService
.
GetStorage
(
solution
,
checkBranchId
:
true
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录