Skip to content

Commit

Permalink
Merge branch 'development' of github.com:Washi1337/AsmResolver into d…
Browse files Browse the repository at this point in the history
…evelopment
  • Loading branch information
Washi1337 committed Sep 17, 2022
2 parents 69a5196 + dd01769 commit b32727e
Show file tree
Hide file tree
Showing 30 changed files with 31 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace AsmResolver.DotNet.Signatures
/// <summary>
/// Describes a context in which a blob signature is to be serialized in.
/// </summary>
public class BlobSerializationContext
public readonly struct BlobSerializationContext
{
/// <summary>
/// Creates a new instance of the <see cref="BlobSerializationContext"/> class.
Expand Down
2 changes: 1 addition & 1 deletion src/AsmResolver.DotNet/Signatures/BlobSignature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public abstract class BlobSignature
/// <summary>
/// Serializes the blob to an output stream.
/// </summary>
public abstract void Write(BlobSerializationContext context);
public abstract void Write(in BlobSerializationContext context);

/// <summary>
/// Wraps the blob signature into a new stand-alone signature that can be referenced by a metadata token.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

namespace AsmResolver.DotNet.Signatures
{
internal sealed class CustomAttributeArgumentWriter
internal readonly struct CustomAttributeArgumentWriter
{
private readonly BlobSerializationContext _context;

public CustomAttributeArgumentWriter(BlobSerializationContext context)
{
_context = context ?? throw new ArgumentNullException(nameof(context));
_context = context;
}

public void WriteArgument(CustomAttributeArgument argument)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public override string ToString()
}

/// <inheritdoc />
protected override void WriteContents(BlobSerializationContext context)
protected override void WriteContents(in BlobSerializationContext context)
{
context.Writer.WriteUInt16(CustomAttributeSignaturePrologue);

Expand Down
2 changes: 1 addition & 1 deletion src/AsmResolver.DotNet/Signatures/DataBlobSignature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public object InterpretData(ElementType elementType)
}

/// <inheritdoc />
public override void Write(BlobSerializationContext context) => context.Writer.WriteBytes(Data);
public override void Write(in BlobSerializationContext context) => context.Writer.WriteBytes(Data);

/// <summary>
/// Create a <see cref="DataBlobSignature"/> from a value
Expand Down
4 changes: 2 additions & 2 deletions src/AsmResolver.DotNet/Signatures/ExtendableBlobSignature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public byte[]? ExtraData
}

/// <inheritdoc />
public sealed override void Write(BlobSerializationContext context)
public sealed override void Write(in BlobSerializationContext context)
{
WriteContents(context);
if (ExtraData is not null)
Expand All @@ -27,6 +27,6 @@ public sealed override void Write(BlobSerializationContext context)
/// <summary>
/// Serializes the blob (without extra data) to an output stream.
/// </summary>
protected abstract void WriteContents(BlobSerializationContext context);
protected abstract void WriteContents(in BlobSerializationContext context);
}
}
2 changes: 1 addition & 1 deletion src/AsmResolver.DotNet/Signatures/FieldSignature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public FieldSignature InstantiateGenericTypes(GenericContext context) =>
GenericTypeActivator.Instance.InstantiateFieldSignature(this, context);

/// <inheritdoc />
protected override void WriteContents(BlobSerializationContext context)
protected override void WriteContents(in BlobSerializationContext context)
{
context.Writer.WriteByte((byte) Attributes);
FieldType.Write(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public IList<TypeSignature> TypeArguments
}

/// <inheritdoc />
protected override void WriteContents(BlobSerializationContext context)
protected override void WriteContents(in BlobSerializationContext context)
{
var writer = context.Writer;
writer.WriteByte((byte) Attributes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ protected override CallingConventionSignature ImportWithInternal(ReferenceImport
ImportWith(importer);

/// <inheritdoc />
protected override void WriteContents(BlobSerializationContext context)
protected override void WriteContents(in BlobSerializationContext context)
{
var writer = context.Writer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public int? IidParameterIndex
}

/// <inheritdoc />
protected override void WriteContents(BlobSerializationContext context)
protected override void WriteContents(in BlobSerializationContext context)
{
var writer = context.Writer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public Utf8String? Cookie
}

/// <inheritdoc />
protected override void WriteContents(BlobSerializationContext context)
protected override void WriteContents(in BlobSerializationContext context)
{
var writer = context.Writer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public NativeType? ArrayElementType
}

/// <inheritdoc />
protected override void WriteContents(BlobSerializationContext context)
protected override void WriteContents(in BlobSerializationContext context)
{
var writer = context.Writer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public int Size
}

/// <inheritdoc />
protected override void WriteContents(BlobSerializationContext context)
protected override void WriteContents(in BlobSerializationContext context)
{
var writer = context.Writer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public LPArrayFlags? Flags
}

/// <inheritdoc />
protected override void WriteContents(BlobSerializationContext context)
protected override void WriteContents(in BlobSerializationContext context)
{
var writer = context.Writer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public TypeSignature? UserDefinedSubType
}

/// <inheritdoc />
protected override void WriteContents(BlobSerializationContext context)
protected override void WriteContents(in BlobSerializationContext context)
{
var writer = context.Writer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public override NativeType NativeType
}

/// <inheritdoc />
protected override void WriteContents(BlobSerializationContext context)
protected override void WriteContents(in BlobSerializationContext context)
{
context.Writer.WriteByte((byte) NativeType);
}
Expand Down
2 changes: 1 addition & 1 deletion src/AsmResolver.DotNet/Signatures/MethodSignature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public MethodSignature InstantiateGenericTypes(GenericContext context)
public FunctionPointerTypeSignature MakeFunctionPointerType() => new(this);

/// <inheritdoc />
protected override void WriteContents(BlobSerializationContext context)
protected override void WriteContents(in BlobSerializationContext context)
{
var writer = context.Writer;

Expand Down
2 changes: 1 addition & 1 deletion src/AsmResolver.DotNet/Signatures/PropertySignature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public PropertySignature InstantiateGenericTypes(GenericContext context)
=> GenericTypeActivator.Instance.InstantiatePropertySignature(this, context);

/// <inheritdoc />
protected override void WriteContents(BlobSerializationContext context)
protected override void WriteContents(in BlobSerializationContext context)
{
context.Writer.WriteByte((byte) Attributes);
WriteParametersAndReturnType(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public IList<SecurityAttribute> Attributes
} = new List<SecurityAttribute>();

/// <inheritdoc />
protected override void WriteContents(BlobSerializationContext context)
protected override void WriteContents(in BlobSerializationContext context)
{
var writer = context.Writer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected override void Initialize(
}

/// <inheritdoc />
protected override void WriteContents(BlobSerializationContext context)
protected override void WriteContents(in BlobSerializationContext context)
{
// If the arguments are not initialized yet, it means nobody accessed the fixed or named arguments of the
// signature. In such a case, we can safely assume nothing has changed to the signature.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public override TResult AcceptVisitor<TState, TResult>(ITypeSignatureVisitor<TSt
visitor.VisitArrayType(this, state);

/// <inheritdoc />
protected override void WriteContents(BlobSerializationContext context)
protected override void WriteContents(in BlobSerializationContext context)
{
if (!Validate())
throw new InvalidOperationException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public override IResolutionScope? Scope
public override ITypeDefOrRef ToTypeDefOrRef() => Type;

/// <inheritdoc />
protected override void WriteContents(BlobSerializationContext context) =>
protected override void WriteContents(in BlobSerializationContext context) =>
context.Writer.WriteByte((byte) ElementType);

/// <inheritdoc />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public override bool IsImportedInModule(ModuleDefinition module) =>
ModifierType.IsImportedInModule(module) && base.IsImportedInModule(module);

/// <inheritdoc />
protected override void WriteContents(BlobSerializationContext context)
protected override void WriteContents(in BlobSerializationContext context)
{
context.Writer.WriteByte((byte) ElementType);
WriteTypeDefOrRef(context, ModifierType, "Modifier type");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public MethodSignature Signature
public override bool IsImportedInModule(ModuleDefinition module) => Signature.IsImportedInModule(module);

/// <inheritdoc />
protected override void WriteContents(BlobSerializationContext context)
protected override void WriteContents(in BlobSerializationContext context)
{
context.Writer.WriteByte((byte) ElementType);
Signature.Write(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public override bool IsImportedInModule(ModuleDefinition module)
}

/// <inheritdoc />
protected override void WriteContents(BlobSerializationContext context)
protected override void WriteContents(in BlobSerializationContext context)
{
var writer = context.Writer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public override IResolutionScope? Scope
public override ITypeDefOrRef? GetUnderlyingTypeDefOrRef() => null;

/// <inheritdoc />
protected override void WriteContents(BlobSerializationContext context)
protected override void WriteContents(in BlobSerializationContext context)
{
var writer = context.Writer;
writer.WriteByte((byte) ElementType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class SentinelTypeSignature : TypeSignature
public override bool IsImportedInModule(ModuleDefinition module) => true;

/// <inheritdoc />
protected override void WriteContents(BlobSerializationContext context) =>
protected override void WriteContents(in BlobSerializationContext context) =>
context.Writer.WriteByte((byte) ElementType);

/// <inheritdoc />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public override TResult AcceptVisitor<TState, TResult>(ITypeSignatureVisitor<TSt
visitor.VisitTypeDefOrRef(this, state);

/// <inheritdoc />
protected override void WriteContents(BlobSerializationContext context)
protected override void WriteContents(in BlobSerializationContext context)
{
var writer = context.Writer;
writer.WriteByte((byte) ElementType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public TypeSignature BaseType
public override bool IsImportedInModule(ModuleDefinition module) => BaseType.IsImportedInModule(module);

/// <inheritdoc />
protected override void WriteContents(BlobSerializationContext context)
protected override void WriteContents(in BlobSerializationContext context)
{
context.Writer.WriteByte((byte) ElementType);
WriteBaseType(context);
Expand Down
5 changes: 0 additions & 5 deletions test/AsmResolver.DotNet.Tests/ModuleDefinitionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using AsmResolver.DotNet.Builder;
using AsmResolver.DotNet.Cloning;
using AsmResolver.DotNet.Serialized;
using AsmResolver.DotNet.Signatures;
using AsmResolver.DotNet.TestCases.NestedClasses;
using AsmResolver.IO;
using AsmResolver.PE.DotNet.Builder;
using AsmResolver.PE.DotNet.Metadata.Strings;
using AsmResolver.PE.DotNet.Metadata.Tables;
using AsmResolver.PE.Win32Resources;
using Xunit;
Expand Down

0 comments on commit b32727e

Please sign in to comment.