Skip to content

Commit

Permalink
Added partial support for net35
Browse files Browse the repository at this point in the history
  • Loading branch information
Aragas committed Apr 5, 2024
1 parent 2e3492b commit 093ddbd
Show file tree
Hide file tree
Showing 28 changed files with 582 additions and 23 deletions.
14 changes: 14 additions & 0 deletions src/BUTR.CrashReport.Models/Analyzer/GenericSuggestedFix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,18 @@ public sealed record GenericSuggestedFix
/// The type of suggested fix.
/// </summary>
public required GenericSuggestedFixType Type { get; set; }

/// <inheritdoc />
public bool Equals(GenericSuggestedFix? other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return Type == other.Type;
}

/// <inheritdoc />
public override int GetHashCode()
{
return (int) Type;
}
}
17 changes: 17 additions & 0 deletions src/BUTR.CrashReport.Models/Analyzer/ModuleSuggestedFix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,21 @@ public sealed record ModuleSuggestedFix
/// The type of suggested fix.
/// </summary>
public required ModuleSuggestedFixType Type { get; set; }

/// <inheritdoc />
public bool Equals(ModuleSuggestedFix? other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return ModuleId == other.ModuleId && Type == other.Type;
}

/// <inheritdoc />
public override int GetHashCode()
{
unchecked
{
return (ModuleId.GetHashCode() * 397) ^ (int) Type;
}
}
}
20 changes: 20 additions & 0 deletions src/BUTR.CrashReport.Models/Analyzer/ModuleUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,24 @@ public sealed record ModuleUpdate
/// Whether the module was involced in the crash.
/// </summary>
public required bool IsModuleInvolved { get; set; }

/// <inheritdoc />
public bool Equals(ModuleUpdate? other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return ModuleId == other.ModuleId && ModuleVersion == other.ModuleVersion && IsModuleInvolved == other.IsModuleInvolved;
}

/// <inheritdoc />
public override int GetHashCode()
{
unchecked
{
var hashCode = ModuleId.GetHashCode();
hashCode = (hashCode * 397) ^ ModuleVersion.GetHashCode();
hashCode = (hashCode * 397) ^ IsModuleInvolved.GetHashCode();
return hashCode;
}
}
}
22 changes: 18 additions & 4 deletions src/BUTR.CrashReport.Models/AssemblyIdModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,24 @@ public sealed record AssemblyIdModel : IEquatable<AssemblyModel>, IEquatable<Ass
public required string? PublicKeyToken { get; set; }

/// <inheritdoc />
public bool Equals(AssemblyIdModel? other) => other is not null &&
Name == other.Name &&
((Version is null || other.Version is null) || Version == other.Version) &&
PublicKeyToken == other.PublicKeyToken;
public bool Equals(AssemblyIdModel? other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return Name == other.Name && Version == other.Version && PublicKeyToken == other.PublicKeyToken;
}

/// <inheritdoc />
public override int GetHashCode()
{
unchecked
{
var hashCode = Name.GetHashCode();
hashCode = (hashCode * 397) ^ (Version != null ? Version.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (PublicKeyToken != null ? PublicKeyToken.GetHashCode() : 0);
return hashCode;
}
}

/// <inheritdoc />
public bool Equals(AssemblyModel? other) => other is not null && other.Id.Equals(this);
Expand Down
23 changes: 22 additions & 1 deletion src/BUTR.CrashReport.Models/AssemblyImportedReferenceModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// <summary>
/// Represents an imported assembly reference.
/// </summary>
public record AssemblyImportedReferenceModel
public sealed record AssemblyImportedReferenceModel
{
/// <summary>
/// <inheritdoc cref="System.Reflection.AssemblyName.Name"/>
Expand Down Expand Up @@ -33,4 +33,25 @@ public record AssemblyImportedReferenceModel
/// The empty default constructor.
/// </summary>
public AssemblyImportedReferenceModel() { }

/// <inheritdoc />
public bool Equals(AssemblyImportedReferenceModel? other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return Name == other.Name && Version == other.Version && Culture == other.Culture && PublicKeyToken == other.PublicKeyToken;
}

/// <inheritdoc />
public override int GetHashCode()
{
unchecked
{
var hashCode = Name.GetHashCode();
hashCode = (hashCode * 397) ^ Version.GetHashCode();
hashCode = (hashCode * 397) ^ (Culture != null ? Culture.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (PublicKeyToken != null ? PublicKeyToken.GetHashCode() : 0);
return hashCode;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// <summary>
/// Represents an imported type reference.
/// </summary>
public record AssemblyImportedTypeReferenceModel
public sealed record AssemblyImportedTypeReferenceModel
{
/// <summary>
/// <inheritdoc cref="AsmResolver.DotNet.TypeReference.Name"/>
Expand All @@ -22,4 +22,24 @@ public record AssemblyImportedTypeReferenceModel
/// </summary>
/// <returns><inheritdoc cref="AsmResolver.DotNet.TypeReference.FullName"/></returns>
public required string FullName { get; set; }

/// <inheritdoc />
public bool Equals(AssemblyImportedTypeReferenceModel? other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return Name == other.Name && Namespace == other.Namespace && FullName == other.FullName;
}

/// <inheritdoc />
public override int GetHashCode()
{
unchecked
{
var hashCode = Name.GetHashCode();
hashCode = (hashCode * 397) ^ Namespace.GetHashCode();
hashCode = (hashCode * 397) ^ FullName.GetHashCode();
return hashCode;
}
}
}
30 changes: 29 additions & 1 deletion src/BUTR.CrashReport.Models/AssemblyModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace BUTR.CrashReport.Models;
/// <summary>
/// Represents a .NET assembly.
/// </summary>
public record AssemblyModel
public sealed record AssemblyModel
{
/// <summary>
/// <inheritdoc cref="ModuleModel.Id"/> Is null if not from a module.
Expand Down Expand Up @@ -66,4 +66,32 @@ public record AssemblyModel
/// </summary>
/// <returns><inheritdoc cref="CrashReportModel.AdditionalMetadata"/></returns>
public required IList<MetadataModel> AdditionalMetadata { get; set; } = new List<MetadataModel>();

/// <inheritdoc />
public bool Equals(AssemblyModel? other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return ModuleId == other.ModuleId && LoaderPluginId == other.LoaderPluginId && Id.Equals(other.Id) && CultureName == other.CultureName && Architecture == other.Architecture && Hash == other.Hash && AnonymizedPath == other.AnonymizedPath && Type == other.Type && ImportedTypeReferences.Equals(other.ImportedTypeReferences) && ImportedAssemblyReferences.Equals(other.ImportedAssemblyReferences) && AdditionalMetadata.Equals(other.AdditionalMetadata);
}

/// <inheritdoc />
public override int GetHashCode()
{
unchecked
{
var hashCode = (ModuleId != null ? ModuleId.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (LoaderPluginId != null ? LoaderPluginId.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ Id.GetHashCode();
hashCode = (hashCode * 397) ^ (CultureName != null ? CultureName.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ Architecture.GetHashCode();
hashCode = (hashCode * 397) ^ Hash.GetHashCode();
hashCode = (hashCode * 397) ^ AnonymizedPath.GetHashCode();
hashCode = (hashCode * 397) ^ (int) Type;
hashCode = (hashCode * 397) ^ ImportedTypeReferences.GetHashCode();
hashCode = (hashCode * 397) ^ ImportedAssemblyReferences.GetHashCode();
hashCode = (hashCode * 397) ^ AdditionalMetadata.GetHashCode();
return hashCode;
}
}
}
4 changes: 2 additions & 2 deletions src/BUTR.CrashReport.Models/BUTR.CrashReport.Models.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>net35;net45;netstandard2.0</TargetFrameworks>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down Expand Up @@ -31,7 +31,7 @@

<ItemGroup>
<PackageReference Include="SauceControl.InheritDoc" Version="2.0.1" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
<PackageReference Include="Required" Version="1.0.0" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
<PackageReference Include="RequiredMemberAttribute" Version="1.0.0" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
</ItemGroup>

</Project>
19 changes: 18 additions & 1 deletion src/BUTR.CrashReport.Models/CapabilityModuleOrPluginModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// <summary>
/// Represents the functionality that is used by the module or plugin.
/// </summary>
public record CapabilityModuleOrPluginModel
public sealed record CapabilityModuleOrPluginModel
{
/// <summary>
/// The name of the capability.
Expand All @@ -19,4 +19,21 @@ public record CapabilityModuleOrPluginModel
/// Creates a new instance of <see cref="CapabilityModuleOrPluginModel"/>.
/// </summary>
public CapabilityModuleOrPluginModel(string name) => Name = name;

/// <inheritdoc />
public bool Equals(CapabilityModuleOrPluginModel? other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return Name == other.Name && Description == other.Description;
}

/// <inheritdoc />
public override int GetHashCode()
{
unchecked
{
return (Name.GetHashCode() * 397) ^ Description.GetHashCode();
}
}
}
27 changes: 26 additions & 1 deletion src/BUTR.CrashReport.Models/CrashReportMetadataModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace BUTR.CrashReport.Models;
/// <summary>
/// Represents the metadata for a crash report.
/// </summary>
public record CrashReportMetadataModel
public sealed record CrashReportMetadataModel
{
/// <summary>
/// The game name.
Expand Down Expand Up @@ -47,4 +47,29 @@ public record CrashReportMetadataModel
/// </summary>
/// <returns><inheritdoc cref="CrashReportModel.AdditionalMetadata"/></returns>
public required IList<MetadataModel> AdditionalMetadata { get; set; } = new List<MetadataModel>();

/// <inheritdoc />
public bool Equals(CrashReportMetadataModel? other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return GameName == other.GameName && GameVersion == other.GameVersion && LoaderPluginProviderName == other.LoaderPluginProviderName && LoaderPluginProviderVersion == other.LoaderPluginProviderVersion && LauncherType == other.LauncherType && LauncherVersion == other.LauncherVersion && Runtime == other.Runtime && AdditionalMetadata.Equals(other.AdditionalMetadata);
}

/// <inheritdoc />
public override int GetHashCode()
{
unchecked
{
var hashCode = (GameName != null ? GameName.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ GameVersion.GetHashCode();
hashCode = (hashCode * 397) ^ (LoaderPluginProviderName != null ? LoaderPluginProviderName.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (LoaderPluginProviderVersion != null ? LoaderPluginProviderVersion.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (LauncherType != null ? LauncherType.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (LauncherVersion != null ? LauncherVersion.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (Runtime != null ? Runtime.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ AdditionalMetadata.GetHashCode();
return hashCode;
}
}
}
31 changes: 30 additions & 1 deletion src/BUTR.CrashReport.Models/CrashReportModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace BUTR.CrashReport.Models;
/// <summary>
/// Represents the main model of a crash report.
/// </summary>
public record CrashReportModel
public sealed record CrashReportModel
{
/// <summary>
/// The id of the crash report.
Expand Down Expand Up @@ -77,4 +77,33 @@ public record CrashReportModel
/// </summary>
/// <returns>A key:value list of metadatas.</returns>
public required IList<MetadataModel> AdditionalMetadata { get; set; } = new List<MetadataModel>();

/// <inheritdoc />
public bool Equals(CrashReportModel? other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return Id.Equals(other.Id) && Version == other.Version && Exception.Equals(other.Exception) && Metadata.Equals(other.Metadata) && Modules.Equals(other.Modules) && InvolvedModules.Equals(other.InvolvedModules) && EnhancedStacktrace.Equals(other.EnhancedStacktrace) && Assemblies.Equals(other.Assemblies) && HarmonyPatches.Equals(other.HarmonyPatches) && LoaderPlugins.Equals(other.LoaderPlugins) && InvolvedLoaderPlugins.Equals(other.InvolvedLoaderPlugins) && AdditionalMetadata.Equals(other.AdditionalMetadata);
}

/// <inheritdoc />
public override int GetHashCode()
{
unchecked
{
var hashCode = Id.GetHashCode();
hashCode = (hashCode * 397) ^ Version.GetHashCode();
hashCode = (hashCode * 397) ^ Exception.GetHashCode();
hashCode = (hashCode * 397) ^ Metadata.GetHashCode();
hashCode = (hashCode * 397) ^ Modules.GetHashCode();
hashCode = (hashCode * 397) ^ InvolvedModules.GetHashCode();
hashCode = (hashCode * 397) ^ EnhancedStacktrace.GetHashCode();
hashCode = (hashCode * 397) ^ Assemblies.GetHashCode();
hashCode = (hashCode * 397) ^ HarmonyPatches.GetHashCode();
hashCode = (hashCode * 397) ^ LoaderPlugins.GetHashCode();
hashCode = (hashCode * 397) ^ InvolvedLoaderPlugins.GetHashCode();
hashCode = (hashCode * 397) ^ AdditionalMetadata.GetHashCode();
return hashCode;
}
}
}
25 changes: 24 additions & 1 deletion src/BUTR.CrashReport.Models/DependencyMetadataModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace BUTR.CrashReport.Models;
/// <summary>
/// Represents the dependency metadata for a module.
/// </summary>
public record DependencyMetadataModel
public sealed record DependencyMetadataModel
{
/// <summary>
/// <inheritdoc cref="ModuleModel.Id"/> Is null if not from a module.
Expand Down Expand Up @@ -38,4 +38,27 @@ public record DependencyMetadataModel
/// </summary>
/// <returns><inheritdoc cref="CrashReportModel.AdditionalMetadata"/></returns>
public required IList<MetadataModel> AdditionalMetadata { get; set; } = new List<MetadataModel>();

/// <inheritdoc />
public bool Equals(DependencyMetadataModel? other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return ModuleOrPluginId == other.ModuleOrPluginId && Type == other.Type && IsOptional == other.IsOptional && Version == other.Version && VersionRange == other.VersionRange && AdditionalMetadata.Equals(other.AdditionalMetadata);
}

/// <inheritdoc />
public override int GetHashCode()
{
unchecked
{
var hashCode = ModuleOrPluginId.GetHashCode();
hashCode = (hashCode * 397) ^ (int) Type;
hashCode = (hashCode * 397) ^ IsOptional.GetHashCode();
hashCode = (hashCode * 397) ^ (Version != null ? Version.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (VersionRange != null ? VersionRange.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ AdditionalMetadata.GetHashCode();
return hashCode;
}
}
}
Loading

0 comments on commit 093ddbd

Please sign in to comment.