Skip to content

Commit

Permalink
Merge pull request #338 from JPaja/development
Browse files Browse the repository at this point in the history
Make TypeDefOrRefSignature.Type settable
  • Loading branch information
Washi1337 authored Aug 10, 2022
2 parents b3f0444 + b78c244 commit fb63f8c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ namespace AsmResolver.DotNet.Signatures.Types
public class GenericInstanceTypeSignature : TypeSignature, IGenericArgumentsProvider
{
private readonly List<TypeSignature> _typeArguments;
private ITypeDefOrRef _genericType;
private bool _isValueType;

internal new static GenericInstanceTypeSignature FromReader(in BlobReadContext context, ref BinaryStreamReader reader)
{
Expand Down Expand Up @@ -57,7 +59,7 @@ private GenericInstanceTypeSignature(ITypeDefOrRef genericType, bool isValueType
{
GenericType = genericType;
_typeArguments = new List<TypeSignature>(typeArguments);
IsValueType = isValueType;
_isValueType = isValueType;
}

/// <inheritdoc />
Expand All @@ -68,8 +70,12 @@ private GenericInstanceTypeSignature(ITypeDefOrRef genericType, bool isValueType
/// </summary>
public ITypeDefOrRef GenericType
{
get;
set;
get => _genericType;
set
{
_genericType = value;
_isValueType = _genericType.IsValueType;
}
}

/// <summary>
Expand Down Expand Up @@ -97,10 +103,7 @@ public override string? Name
public override ModuleDefinition? Module => GenericType.Module;

/// <inheritdoc />
public override bool IsValueType
{
get;
}
public override bool IsValueType => _isValueType;

/// <inheritdoc />
public override TypeDefinition? Resolve() => GenericType.Resolve();
Expand Down
18 changes: 11 additions & 7 deletions src/AsmResolver.DotNet/Signatures/Types/TypeDefOrRefSignature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ namespace AsmResolver.DotNet.Signatures.Types
/// </summary>
public class TypeDefOrRefSignature : TypeSignature
{
private ITypeDefOrRef _type;
private bool _isValueType;

/// <summary>
/// Creates a new type signature referencing a type in a type metadata table.
/// </summary>
Expand All @@ -24,16 +27,20 @@ public TypeDefOrRefSignature(ITypeDefOrRef type)
public TypeDefOrRefSignature(ITypeDefOrRef type, bool isValueType)
{
Type = type;
IsValueType = isValueType;

_isValueType = isValueType;
}

/// <summary>
/// Gets the metadata type that is referenced by this signature.
/// </summary>
public ITypeDefOrRef Type
{
get;
get => _type;
set
{
_type = value;
_isValueType = value.IsValueType;
}
}

/// <inheritdoc />
Expand All @@ -52,10 +59,7 @@ public ITypeDefOrRef Type
public override ModuleDefinition? Module => Type.Module;

/// <inheritdoc />
public override bool IsValueType
{
get;
}
public override bool IsValueType => _isValueType;

/// <inheritdoc />
public override TypeDefinition? Resolve() => Type.Resolve();
Expand Down

0 comments on commit fb63f8c

Please sign in to comment.