Skip to content

Commit

Permalink
Replace string parameters in constructors with Utf8String parameters.
Browse files Browse the repository at this point in the history
  • Loading branch information
Washi1337 committed Nov 27, 2022
1 parent 533a911 commit 5d8cb88
Show file tree
Hide file tree
Showing 19 changed files with 29 additions and 31 deletions.
10 changes: 4 additions & 6 deletions src/AsmResolver.DotNet/AssemblyDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ protected AssemblyDefinition(MetadataToken token)
/// </summary>
/// <param name="name">The name of the assembly.</param>
/// <param name="version">The version of the assembly.</param>
public AssemblyDefinition(string? name, Version version)
public AssemblyDefinition(Utf8String? name, Version version)
: this(new MetadataToken(TableIndex.Assembly, 0))
{
Name = name;
Expand Down Expand Up @@ -290,11 +290,9 @@ public void Write(string filePath, IPEImageBuilder imageBuilder, IPEFileBuilder
for (int i = 0; i < Modules.Count; i++)
{
var module = Modules[i];
string modulePath;
if (module == ManifestModule)
modulePath = filePath;
else
modulePath = Path.Combine(directory, module.Name ?? $"module{i}.bin");
string modulePath = module == ManifestModule
? filePath
: Path.Combine(directory, module.Name?.Value ?? $"module{i}.bin");

module.Write(modulePath, imageBuilder, fileBuilder);
}
Expand Down
4 changes: 2 additions & 2 deletions src/AsmResolver.DotNet/AssemblyReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected AssemblyReference(MetadataToken token)
/// </summary>
/// <param name="name">The name of the assembly.</param>
/// <param name="version">The version of the assembly.</param>
public AssemblyReference(string? name, Version version)
public AssemblyReference(Utf8String? name, Version version)
: this(new MetadataToken(TableIndex.AssemblyRef, 0))
{
Name = name;
Expand All @@ -51,7 +51,7 @@ public AssemblyReference(string? name, Version version)
/// unhashed public key used to verify the authenticity of the assembly.</param>
/// <param name="publicKeyOrToken">Indicates the public key or token (depending on <paramref name="publicKey"/>),
/// used to verify the authenticity of the assembly.</param>
public AssemblyReference(string? name, Version version, bool publicKey, byte[]? publicKeyOrToken)
public AssemblyReference(Utf8String? name, Version version, bool publicKey, byte[]? publicKeyOrToken)
: this(new MetadataToken(TableIndex.AssemblyRef, 0))
{
Name = name;
Expand Down
2 changes: 1 addition & 1 deletion src/AsmResolver.DotNet/DefaultMetadataResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public TypeResolution(IAssemblyResolver resolver)
}
}

private TypeDefinition? FindTypeInAssembly(AssemblyDefinition assembly, string? ns, string name)
private TypeDefinition? FindTypeInAssembly(AssemblyDefinition assembly, Utf8String? ns, Utf8String name)
{
for (int i = 0; i < assembly.Modules.Count; i++)
{
Expand Down
2 changes: 1 addition & 1 deletion src/AsmResolver.DotNet/EventDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected EventDefinition(MetadataToken token)
/// <param name="name">The name of the property.</param>
/// <param name="attributes">The attributes.</param>
/// <param name="eventType">The delegate type of the event.</param>
public EventDefinition(string? name, EventAttributes attributes, ITypeDefOrRef? eventType)
public EventDefinition(Utf8String? name, EventAttributes attributes, ITypeDefOrRef? eventType)
: this(new MetadataToken(TableIndex.Event,0))
{
Name = name;
Expand Down
4 changes: 2 additions & 2 deletions src/AsmResolver.DotNet/FieldDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected FieldDefinition(MetadataToken token)
/// <param name="name">The name of the field.</param>
/// <param name="attributes">The attributes.</param>
/// <param name="signature">The signature of the field.</param>
public FieldDefinition(string? name, FieldAttributes attributes, FieldSignature? signature)
public FieldDefinition(Utf8String? name, FieldAttributes attributes, FieldSignature? signature)
: this(new MetadataToken(TableIndex.Field, 0))
{
Name = name;
Expand All @@ -71,7 +71,7 @@ public FieldDefinition(string? name, FieldAttributes attributes, FieldSignature?
/// <param name="name">The name of the field.</param>
/// <param name="attributes">The attributes.</param>
/// <param name="fieldType">The type of values the field contains.</param>
public FieldDefinition(string? name, FieldAttributes attributes, TypeSignature? fieldType)
public FieldDefinition(Utf8String name, FieldAttributes attributes, TypeSignature? fieldType)
: this(new MetadataToken(TableIndex.Field, 0))
{
Name = name;
Expand Down
2 changes: 1 addition & 1 deletion src/AsmResolver.DotNet/FileReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected FileReference(MetadataToken token)
/// </summary>
/// <param name="name">The name of the file.</param>
/// <param name="attributes">The attributes associated to the reference.</param>
public FileReference(string? name, FileAttributes attributes)
public FileReference(Utf8String? name, FileAttributes attributes)
: this(new MetadataToken(TableIndex.File, 0))
{
Name = name;
Expand Down
4 changes: 2 additions & 2 deletions src/AsmResolver.DotNet/GenericParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected GenericParameter(MetadataToken token)
/// Creates a new generic parameter.
/// </summary>
/// <param name="name">The name of the parameter.</param>
public GenericParameter(string? name)
public GenericParameter(Utf8String? name)
: this(new MetadataToken(TableIndex.GenericParam, 0))
{
Name = name;
Expand All @@ -47,7 +47,7 @@ public GenericParameter(string? name)
/// </summary>
/// <param name="name">The name of the parameter.</param>
/// <param name="attributes">Additional attributes to assign to the parameter.</param>
public GenericParameter(string? name, GenericParameterAttributes attributes)
public GenericParameter(Utf8String? name, GenericParameterAttributes attributes)
: this(new MetadataToken(TableIndex.GenericParam, 0))
{
Name = name;
Expand Down
2 changes: 1 addition & 1 deletion src/AsmResolver.DotNet/IFieldDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public interface IFieldDescriptor : IMemberDescriptor, IMetadataMember
/// <summary>
/// Gets the name of the field.
/// </summary>
new Utf8String Name
new Utf8String? Name
{
get;
}
Expand Down
2 changes: 1 addition & 1 deletion src/AsmResolver.DotNet/IMethodDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public interface IMethodDescriptor : IMemberDescriptor, IMetadataMember
/// <summary>
/// Gets the name of the method.
/// </summary>
new Utf8String Name
new Utf8String? Name
{
get;
}
Expand Down
2 changes: 1 addition & 1 deletion src/AsmResolver.DotNet/ImplementationMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected ImplementationMap(MetadataToken token)
/// <param name="scope">The scope that declares the imported member.</param>
/// <param name="name">The name of the imported member.</param>
/// <param name="attributes">The attributes associated to the implementation mapping.</param>
public ImplementationMap(ModuleReference? scope, string? name, ImplementationMapAttributes attributes)
public ImplementationMap(ModuleReference? scope, Utf8String? name, ImplementationMapAttributes attributes)
: this(new MetadataToken(TableIndex.ImplMap, 0))
{
Scope = scope;
Expand Down
4 changes: 2 additions & 2 deletions src/AsmResolver.DotNet/ManifestResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected ManifestResource(MetadataToken token)
/// <param name="attributes">The attributes of the resource.</param>
/// <param name="implementation">The location of the resource data.</param>
/// <param name="offset">The offset within the file referenced by <paramref name="implementation"/> where the data starts.</param>
public ManifestResource(string? name, ManifestResourceAttributes attributes, IImplementation? implementation, uint offset)
public ManifestResource(Utf8String? name, ManifestResourceAttributes attributes, IImplementation? implementation, uint offset)
: this(new MetadataToken(TableIndex.ManifestResource, 0))
{
Name = name;
Expand All @@ -57,7 +57,7 @@ public ManifestResource(string? name, ManifestResourceAttributes attributes, IIm
/// <param name="name">The name of the repository.</param>
/// <param name="attributes">The attributes of the resource.</param>
/// <param name="data">The embedded resource data.</param>
public ManifestResource(string? name, ManifestResourceAttributes attributes, ISegment? data)
public ManifestResource(Utf8String? name, ManifestResourceAttributes attributes, ISegment? data)
: this(new MetadataToken(TableIndex.ManifestResource, 0))
{
Name = name;
Expand Down
2 changes: 1 addition & 1 deletion src/AsmResolver.DotNet/MemberReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected MemberReference(MetadataToken token)
/// <param name="name">The name of the referenced member.</param>
/// <param name="signature">The signature of the referenced member. This dictates whether the
/// referenced member is a field or a method.</param>
public MemberReference(IMemberRefParent? parent, string? name, MemberSignature? signature)
public MemberReference(IMemberRefParent? parent, Utf8String? name, MemberSignature? signature)
: this(new MetadataToken(TableIndex.MemberRef, 0))
{
Parent = parent;
Expand Down
2 changes: 1 addition & 1 deletion src/AsmResolver.DotNet/MethodDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected MethodDefinition(MetadataToken token)
/// <paramref name="signature"/> is set, the <see cref="MethodAttributes.Static"/> bit should be unset in
/// <paramref name="attributes"/> and vice versa.
/// </remarks>
public MethodDefinition(string? name, MethodAttributes attributes, MethodSignature? signature)
public MethodDefinition(Utf8String? name, MethodAttributes attributes, MethodSignature? signature)
: this(new MetadataToken(TableIndex.Method, 0))
{
Name = name;
Expand Down
2 changes: 1 addition & 1 deletion src/AsmResolver.DotNet/ModuleDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ protected ModuleDefinition(MetadataToken token)
/// Defines a new .NET module that references mscorlib version 4.0.0.0.
/// </summary>
/// <param name="name">The name of the module.</param>
public ModuleDefinition(string? name)
public ModuleDefinition(Utf8String? name)
: this(new MetadataToken(TableIndex.Module, 0))
{
Name = name;
Expand Down
2 changes: 1 addition & 1 deletion src/AsmResolver.DotNet/ModuleReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected ModuleReference(MetadataToken token)
/// Creates a new reference to an external module.
/// </summary>
/// <param name="name">The file name of the module.</param>
public ModuleReference(string? name)
public ModuleReference(Utf8String? name)
: this(new MetadataToken(TableIndex.ModuleRef, 0))
{
Name = name;
Expand Down
4 changes: 2 additions & 2 deletions src/AsmResolver.DotNet/ParameterDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected ParameterDefinition(MetadataToken token)
/// Creates a new parameter definition using the provided name.
/// </summary>
/// <param name="name">The name of the new parameter.</param>
public ParameterDefinition(string? name)
public ParameterDefinition(Utf8String? name)
: this(new MetadataToken(TableIndex.Param, 0))
{
Name = name;
Expand All @@ -57,7 +57,7 @@ public ParameterDefinition(string? name)
/// <param name="sequence">The sequence number of the new parameter.</param>
/// <param name="name">The name of the new parameter.</param>
/// <param name="attributes">The attributes to assign to the parameter.</param>
public ParameterDefinition(ushort sequence, string? name, ParameterAttributes attributes)
public ParameterDefinition(ushort sequence, Utf8String? name, ParameterAttributes attributes)
: this(new MetadataToken(TableIndex.Param, 0))
{
Sequence = sequence;
Expand Down
2 changes: 1 addition & 1 deletion src/AsmResolver.DotNet/PropertyDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected PropertyDefinition(MetadataToken token)
/// <param name="name">The name of the property.</param>
/// <param name="attributes">The attributes.</param>
/// <param name="signature">The signature of the property.</param>
public PropertyDefinition(string? name, PropertyAttributes attributes, PropertySignature? signature)
public PropertyDefinition(Utf8String? name, PropertyAttributes attributes, PropertySignature? signature)
: this(new MetadataToken(TableIndex.Property,0))
{
Name = name;
Expand Down
4 changes: 2 additions & 2 deletions src/AsmResolver.DotNet/TypeDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected TypeDefinition(MetadataToken token)
/// <param name="ns">The namespace the type resides in.</param>
/// <param name="name">The name of the type.</param>
/// <param name="attributes">The attributes associated to the type.</param>
public TypeDefinition(string? ns, string? name, TypeAttributes attributes)
public TypeDefinition(Utf8String? ns, Utf8String? name, TypeAttributes attributes)
: this(ns, name, attributes, null)
{
}
Expand All @@ -75,7 +75,7 @@ public TypeDefinition(string? ns, string? name, TypeAttributes attributes)
/// <param name="name">The name of the type.</param>
/// <param name="attributes">The attributes associated to the type.</param>
/// <param name="baseType">The super class that this type extends.</param>
public TypeDefinition(string? ns, string? name, TypeAttributes attributes, ITypeDefOrRef? baseType)
public TypeDefinition(Utf8String? ns, Utf8String? name, TypeAttributes attributes, ITypeDefOrRef? baseType)
: this(new MetadataToken(TableIndex.TypeDef, 0))
{
Namespace = ns;
Expand Down
4 changes: 2 additions & 2 deletions src/AsmResolver.DotNet/TypeReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected TypeReference(MetadataToken token)
/// <param name="scope">The scope that defines the type.</param>
/// <param name="ns">The namespace the type resides in.</param>
/// <param name="name">The name of the type.</param>
public TypeReference(IResolutionScope? scope, string? ns, string? name)
public TypeReference(IResolutionScope? scope, Utf8String? ns, Utf8String? name)
: this(new MetadataToken(TableIndex.TypeRef, 0))
{
_scope.Value = scope;
Expand All @@ -52,7 +52,7 @@ public TypeReference(IResolutionScope? scope, string? ns, string? name)
/// <param name="scope">The scope that defines the type.</param>
/// <param name="ns">The namespace the type resides in.</param>
/// <param name="name">The name of the type.</param>
public TypeReference(ModuleDefinition? module, IResolutionScope? scope, string? ns, string? name)
public TypeReference(ModuleDefinition? module, IResolutionScope? scope, Utf8String? ns, Utf8String? name)
: this(new MetadataToken(TableIndex.TypeRef, 0))
{
_scope.Value = scope;
Expand Down

0 comments on commit 5d8cb88

Please sign in to comment.