Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed May 8, 2024
1 parent 73da0d1 commit ffd34f2
Show file tree
Hide file tree
Showing 17 changed files with 26 additions and 53 deletions.
7 changes: 5 additions & 2 deletions InfoOf.Fody/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
global using Mono.Cecil;
global using Mono.Cecil.Cil;
global using Fody;
global using Mono.Cecil;
global using Mono.Cecil.Cil;
global using Mono.Cecil.Rocks;
global using Mono.Collections.Generic;
5 changes: 1 addition & 4 deletions InfoOf.Fody/ILProcessor.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Mono.Cecil.Rocks;
using Mono.Collections.Generic;

#nullable enable
#nullable enable

public sealed class ILProcessor : IDisposable
{
Expand Down
3 changes: 0 additions & 3 deletions InfoOf.Fody/MethodProcessor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using Fody;
using Mono.Cecil.Rocks;

public partial class ModuleWeaver
{
void ProcessMethod(MethodDefinition method)
Expand Down
4 changes: 1 addition & 3 deletions InfoOf.Fody/ModuleWeaver.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Fody;

public partial class ModuleWeaver:BaseModuleWeaver
public partial class ModuleWeaver:BaseModuleWeaver
{
List<TypeDefinition> allTypes;

Expand Down
6 changes: 2 additions & 4 deletions InfoOf.Fody/OfConstructor.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
public partial class ModuleWeaver
{
void HandleOfConstructor(Instruction instruction, ILProcessor ilProcessor,
MethodReference ofConstructorReference)
//Info.OfConstructor("AssemblyToProcess","MethodClass");
void HandleOfConstructor(Instruction instruction, ILProcessor ilProcessor, MethodReference ofConstructorReference)
{
//Info.OfConstructor("AssemblyToProcess","MethodClass");

Instruction typeNameInstruction;
List<string> parameters;
Instruction parametersInstruction = null;
Expand Down
4 changes: 1 addition & 3 deletions InfoOf.Fody/OfFieldHandler.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using Fody;

public partial class ModuleWeaver
{
//Info.OfField("AssemblyToProcess","MethodClass","Field");
void HandleOfField(Instruction instruction, ILProcessor ilProcessor, MethodReference ofFieldReference)
{
//Info.OfField("AssemblyToProcess","MethodClass","Field");
var fieldNameInstruction = instruction.Previous;
var fieldName = GetLdString(fieldNameInstruction);

Expand Down
20 changes: 9 additions & 11 deletions InfoOf.Fody/OfIndexerHandler.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
using Fody;

public partial class ModuleWeaver
public partial class ModuleWeaver
{
void HandleOfIndexerGet(Instruction instruction, ILProcessor ilProcessor, MethodReference ofIndexerGetReference)
{
void HandleOfIndexerGet(Instruction instruction, ILProcessor ilProcessor, MethodReference ofIndexerGetReference) =>
HandleOfIndexer(instruction, ilProcessor, ofIndexerGetReference, _ => _.GetMethod, (_, p) => p);
}

void HandleOfIndexerSet(Instruction instruction, ILProcessor ilProcessor, MethodReference ofIndexerSetReference)
{
void HandleOfIndexerSet(Instruction instruction, ILProcessor ilProcessor, MethodReference ofIndexerSetReference) =>
HandleOfIndexer(instruction, ilProcessor, ofIndexerSetReference, _ => _.SetMethod, (d, p) => p.Append(d.PropertyType.Name).ToList());
}

void HandleOfIndexer(Instruction instruction, ILProcessor ilProcessor, MethodReference propertyReference,
Func<PropertyDefinition, MethodDefinition> func, Func<PropertyDefinition, List<string>, List<string>> getParameters)
void HandleOfIndexer(
Instruction instruction,
ILProcessor ilProcessor,
MethodReference propertyReference,
Func<PropertyDefinition, MethodDefinition> func,
Func<PropertyDefinition, List<string>, List<string>> getParameters)
{
var parametersInstruction = instruction.Previous;
var parameters = GetLdString(parametersInstruction).GetParameters();
Expand Down
3 changes: 1 addition & 2 deletions InfoOf.Fody/OfMethodHandler.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
public partial class ModuleWeaver
{
//Info.OfMethod("AssemblyToProcess","MethodClass","InstanceMethod");
void HandleOfMethod(Instruction instruction, ILProcessor ilProcessor, MethodReference ofMethodReference)
{
//Info.OfMethod("AssemblyToProcess","MethodClass","InstanceMethod");

Instruction methodNameInstruction;
List<string> parameters;
Instruction parametersInstruction = null;
Expand Down
10 changes: 2 additions & 8 deletions InfoOf.Fody/OfPropertyHandler.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
using Fody;

public partial class ModuleWeaver
{
void HandleOfPropertyGet(Instruction instruction, ILProcessor ilProcessor, MethodReference ofPropertyGetReference)
{
void HandleOfPropertyGet(Instruction instruction, ILProcessor ilProcessor, MethodReference ofPropertyGetReference) =>
HandleOfProperty(instruction, ilProcessor, ofPropertyGetReference, _ => _.GetMethod);
}

void HandleOfPropertySet(Instruction instruction, ILProcessor ilProcessor, MethodReference ofPropertySetReference)
{
void HandleOfPropertySet(Instruction instruction, ILProcessor ilProcessor, MethodReference ofPropertySetReference) =>
HandleOfProperty(instruction, ilProcessor, ofPropertySetReference, _ => _.SetMethod);
}

void HandleOfProperty(Instruction instruction, ILProcessor ilProcessor, MethodReference propertyReference, Func<PropertyDefinition, MethodDefinition> func)
{
Expand Down
3 changes: 1 addition & 2 deletions InfoOf.Fody/OfTypeHandler.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
public partial class ModuleWeaver
{
//Info.OfType("AssemblyToProcess","TypeClass");
void HandleOfType(Instruction instruction, ILProcessor ilProcessor)
{
//Info.OfType("AssemblyToProcess","TypeClass");

var typeNameInstruction = instruction.Previous;
var typeName = GetLdString(typeNameInstruction);

Expand Down
2 changes: 0 additions & 2 deletions InfoOf.Fody/ParamChecker.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Fody;

public static class ParamChecker
{
public static MethodDefinition FindMethodDefinitions(this TypeDefinition typeDefinition, string methodName, List<string> parameters)
Expand Down
2 changes: 0 additions & 2 deletions InfoOf.Fody/TypeNameParsing/AssemblyNameState.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Fody;

class AssemblyNameState(GenericParameterState parentState) : IState
{
IState childState;
Expand Down
2 changes: 0 additions & 2 deletions InfoOf.Fody/TypeNameParsing/GenericParameterState.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Fody;

class GenericParameterState(TypeNameState parentState) : IState
{
IList<AssemblyNameState> genericParameters = new List<AssemblyNameState>();
Expand Down
2 changes: 0 additions & 2 deletions InfoOf.Fody/TypeNameParsing/TokenReadState.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Fody;

class TokenReadState(IState parentState) : IState
{
public IState OnGenericTypeStart() =>
Expand Down
1 change: 0 additions & 1 deletion InfoOf.Fody/TypeNameParsing/TypeNameParser.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Text;
using Fody;

public static class TypeNameParser
{
Expand Down
2 changes: 0 additions & 2 deletions InfoOf.Fody/TypeNameParsing/TypeNameState.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Fody;

class TypeNameState : IState
{
AssemblyNameState parentState;
Expand Down
3 changes: 3 additions & 0 deletions InfoOf.Fody/TypeReferenceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ public static bool IsNamed(this TypeReference type, string typeName)
{
return true;
}

if (typeName == type.Name)
{
return true;
}

var dotIndex = fullName.IndexOf('.');
if (dotIndex > 0)
{
Expand All @@ -21,6 +23,7 @@ public static bool IsNamed(this TypeReference type, string typeName)
return true;
}
}

return false;
}
}

0 comments on commit ffd34f2

Please sign in to comment.