diff options
author | Mike Voorhees <mrvoorhe@users.noreply.github.com> | 2021-02-12 21:51:43 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-12 21:51:43 +0300 |
commit | 3c4ea3f8f4fcb688194f5f1e501ab01642d4bdf4 (patch) | |
tree | 3a0fd856b1e4c5e096f27c46f618b6619dee4862 /Test | |
parent | 25f85c94787bc51fd91dba9598aba741c4384e51 (diff) |
Add ModuleDefinition.ImmediateRead (#713)
We are going to use this to do a multi stage load in parallel. We will be able to greatly reduce our load times using this new API. The way it's going to work is
Stage 1 - In parallel, load the assemblies with ReadingMode.Deferred.
Stage 2 - Populate our AssemblyResolver with a cache of all read assemblies.
Stage 3 - In parallel, call ImmediateRead.
What I really want is an API to load everything in stage 3. I found that ImmediateRead does not load method bodies. I don't know if/how you want want something like this exposed via the public API. For now I'm iterating the data model and forcing things to load that ImmediateRead did not cover.
Diffstat (limited to 'Test')
-rw-r--r-- | Test/Mono.Cecil.Tests/ModuleTests.cs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Test/Mono.Cecil.Tests/ModuleTests.cs b/Test/Mono.Cecil.Tests/ModuleTests.cs index 5e4bee7..5af2a65 100644 --- a/Test/Mono.Cecil.Tests/ModuleTests.cs +++ b/Test/Mono.Cecil.Tests/ModuleTests.cs @@ -283,6 +283,27 @@ namespace Mono.Cecil.Tests { } } + + [Test] + public void OpenModuleDeferredAndThenPerformImmediateRead () + { + using (var module = GetResourceModule ("hello.exe", ReadingMode.Deferred)) { + Assert.AreEqual (ReadingMode.Deferred, module.ReadingMode); + module.ImmediateRead (); + Assert.AreEqual (ReadingMode.Immediate, module.ReadingMode); + } + } + + [Test] + public void ImmediateReadDoesNothingForModuleWithNoImage () + { + using (var module = new ModuleDefinition ()) { + var initialReadingMode = module.ReadingMode; + module.ImmediateRead (); + Assert.AreEqual (initialReadingMode, module.ReadingMode); + } + } + [Test] public void OwnedStreamModuleFileName () { |