-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix/could not resolve type system.runtime method handle (#6)
* fix typos * fix code * add test cases * remove code * bump version * remove some code
- Loading branch information
1 parent
21da4f0
commit 5c47006
Showing
40 changed files
with
319 additions
and
279 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.1.3 | ||
0.1.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> | ||
<InterfaceBaseInvoke /> | ||
</Weavers> | ||
</Weavers> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 0 additions & 39 deletions
39
src/InterfaceBaseInvoke.Fody/Extensions/CecilExtensions.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,52 @@ | ||
namespace InterfaceBaseInvoke.Fody | ||
namespace InterfaceBaseInvoke.Fody; | ||
|
||
public class ModuleWeaver : BaseModuleWeaver | ||
{ | ||
public class ModuleWeaver : BaseModuleWeaver | ||
private readonly IWeaverLogger _log; | ||
|
||
public ModuleWeaver() | ||
{ | ||
private readonly IWeaverLogger _log; | ||
_log = new WeaverLogger(this); | ||
} | ||
|
||
public ModuleWeaver() | ||
{ | ||
_log = new WeaverLogger(this); | ||
} | ||
public override void Execute() | ||
{ | ||
using var context = new ModuleWeavingContext(ModuleDefinition, WeaverAnchors.AssemblyName, ProjectDirectoryPath); | ||
|
||
public override void Execute() | ||
var processed = false; | ||
foreach (var type in ModuleDefinition.GetTypes()) | ||
{ | ||
foreach (var type in ModuleDefinition.GetTypes()) | ||
foreach (var method in type.Methods) | ||
{ | ||
foreach (var method in type.Methods) | ||
if (method.HasBody == false) | ||
continue; | ||
|
||
_log.Debug($"Processing: {method.FullName}"); | ||
|
||
try | ||
{ | ||
if (ModuleDefinition.IsAssemblyReferenced(method, WeaverAnchors.AssemblyName) == false) | ||
continue; | ||
|
||
_log.Debug($"Processing: {method.FullName}"); | ||
|
||
try | ||
{ | ||
new MethodWeaver(ModuleDefinition, method, _log).Process(); | ||
} | ||
catch (WeavingException ex) | ||
{ | ||
AddError(ex.Message, ex.SequencePoint); | ||
} | ||
processed = new MethodWeaver(context, method, _log).Process() || processed; | ||
} | ||
catch (WeavingException ex) | ||
{ | ||
var terminate = AddError(ex.ToString(), ex.SequencePoint); | ||
if (terminate) | ||
return; | ||
} | ||
} | ||
} | ||
|
||
public override IEnumerable<string> GetAssembliesForScanning() => Enumerable.Empty<string>(); | ||
if (processed == false) | ||
{ | ||
_log.Warning("No type is processed.", null); | ||
} | ||
} | ||
|
||
public override IEnumerable<string> GetAssembliesForScanning() => []; | ||
|
||
protected virtual void AddError(string message, SequencePoint? sequencePoint) | ||
=> _log.Error(message, sequencePoint); | ||
protected virtual bool AddError(string message, SequencePoint? sequencePoint) | ||
{ | ||
_log.Error(message, sequencePoint); | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,47 @@ | ||
namespace InterfaceBaseInvoke.Fody.Processing | ||
namespace InterfaceBaseInvoke.Fody.Processing; | ||
|
||
public sealed class References | ||
{ | ||
public sealed class References | ||
{ | ||
public TypeReferences Types { get; } | ||
public MethodReferences Methods { get; } | ||
public TypeReferences Types { get; } | ||
public MethodReferences Methods { get; } | ||
|
||
public References(ModuleDefinition module) | ||
{ | ||
Types = new TypeReferences(module); | ||
Methods = new MethodReferences(module, Types); | ||
} | ||
public References(ModuleWeavingContext context) | ||
{ | ||
Types = new TypeReferences(context); | ||
Methods = new MethodReferences(context, Types); | ||
} | ||
} | ||
|
||
public sealed class TypeReferences | ||
{ | ||
public TypeReference RuntimeMethodHandle { get; } | ||
public TypeReference IntPtr { get; } | ||
public TypeReference Int32 { get; } | ||
public TypeReference Environment { get; } | ||
public TypeReference Boolean { get; } | ||
public sealed class TypeReferences | ||
{ | ||
public TypeReference RuntimeMethodHandle { get; } | ||
public TypeReference IntPtr { get; } | ||
public TypeReference Int32 { get; } | ||
public TypeReference Environment { get; } | ||
public TypeReference Boolean { get; } | ||
|
||
public TypeReferences(ModuleDefinition module) | ||
{ | ||
Environment = module.ImportReference(typeof(Environment)); | ||
IntPtr = module.ImportReference(typeof(IntPtr)); | ||
Int32 = module.ImportReference(typeof(int)); | ||
RuntimeMethodHandle = module.ImportReference(typeof(RuntimeMethodHandle)); | ||
Boolean = module.ImportReference(typeof(bool)); | ||
} | ||
public TypeReferences(ModuleWeavingContext context) | ||
{ | ||
Environment = context.ImportReference(typeof(Environment)); | ||
IntPtr = context.ImportReference(typeof(IntPtr)); | ||
Int32 = context.ImportReference(typeof(int)); | ||
RuntimeMethodHandle = context.ImportReference(typeof(RuntimeMethodHandle)); | ||
Boolean = context.ImportReference(typeof(bool)); | ||
} | ||
} | ||
|
||
public sealed class MethodReferences | ||
{ | ||
public MethodReference FunctionPointer { get; } | ||
public MethodReference ToInt32 { get; } | ||
public MethodReference ToInt64 { get; } | ||
public MethodReference Is64BitProcess { get; } | ||
public sealed class MethodReferences | ||
{ | ||
public MethodReference FunctionPointer { get; } | ||
public MethodReference ToInt32 { get; } | ||
public MethodReference ToInt64 { get; } | ||
public MethodReference Is64BitProcess { get; } | ||
|
||
public MethodReferences(ModuleDefinition module, TypeReferences types) | ||
{ | ||
FunctionPointer = MethodRefBuilder.MethodByNameAndSignature(module, types.RuntimeMethodHandle, nameof(RuntimeMethodHandle.GetFunctionPointer), 0, types.IntPtr, Enumerable.Empty<TypeReference>()).Build(); | ||
ToInt32 = MethodRefBuilder.MethodByName(module, types.IntPtr, nameof(IntPtr.ToInt32)).Build(); | ||
ToInt64 = MethodRefBuilder.MethodByName(module, types.IntPtr, nameof(IntPtr.ToInt64)).Build(); | ||
Is64BitProcess = MethodRefBuilder.PropertyGet(module, types.Environment, nameof(Environment.Is64BitProcess)).Build(); | ||
} | ||
public MethodReferences(ModuleWeavingContext context, TypeReferences types) | ||
{ | ||
FunctionPointer = MethodRefBuilder.MethodByNameAndSignature(context, types.RuntimeMethodHandle, nameof(RuntimeMethodHandle.GetFunctionPointer), 0, types.IntPtr.ToTypeRefBuilder(context), []).Build(); | ||
ToInt32 = MethodRefBuilder.MethodByName(context, types.IntPtr, nameof(IntPtr.ToInt32)).Build(); | ||
ToInt64 = MethodRefBuilder.MethodByName(context, types.IntPtr, nameof(IntPtr.ToInt64)).Build(); | ||
Is64BitProcess = MethodRefBuilder.PropertyGet(context, types.Environment, nameof(Environment.Is64BitProcess)).Build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.