Skip to content

Commit

Permalink
Merge branch 'dev' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
Noggog committed Mar 22, 2021
2 parents e597ecd + 6508f2f commit 3476051
Show file tree
Hide file tree
Showing 619 changed files with 57,242 additions and 26,050 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/ci-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ jobs:
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.*
- name: Setup .NET Core SDK 3.1.x
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.x
- name: Install dependencies
run: |
dotnet clean -c Release && dotnet nuget locals all --clear
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/ci-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ jobs:
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.*
- name: Setup .NET Core SDK 3.1.x
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.x
- name: Install dependencies
run: |
dotnet clean -c Release && dotnet nuget locals all --clear
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ jobs:
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.*
- name: Setup .NET Core SDK 3.1.x
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.x
- name: Install dependencies
run: |
dotnet clean -c Release && dotnet nuget locals all --clear
Expand Down
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
Returns="$(PackageVersion)">
<PropertyGroup>
<DevLabel Condition="$(GitCommits) != '0'">.1-dev</DevLabel>
<DevLabel Condition="$(GitCommits) == '0' And $(GitSemVerDashLabel) != ''">$(GitSemVerDashLabel)</DevLabel>
<AssemblyDevLabel Condition="$(GitCommits) != '0'">.1</AssemblyDevLabel>
<FileVersion>$(GitBaseVersionMajor).$(GitBaseVersionMinor).$(GitBaseVersionPatch)$(AssemblyDevLabel)</FileVersion>
<PackageVersion>$(GitBaseVersionMajor).$(GitBaseVersionMinor).$(GitBaseVersionPatch)$(DevLabel)</PackageVersion>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net5.0;netstandard2.1</TargetFrameworks>
<TargetFramework>net5.0</TargetFramework>
<TargetPlatformIdentifier>Windows</TargetPlatformIdentifier>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<IsPackable>true</IsPackable>
Expand Down Expand Up @@ -30,7 +30,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
<PackageReference Include="Noggog.CSharpExt" Version="2.7" />
<PackageReference Include="Noggog.CSharpExt" Version="2.10.0" />
<PackageReference Include="NuGetizer" Version="0.6.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
61 changes: 61 additions & 0 deletions Mutagen.Bethesda.Core/Exceptions/MissingRecordException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Mutagen.Bethesda
{
public class MissingRecordException : Exception
{
public FormKey? FormKey { get; }
public string? EditorID { get; }
public Type? Type { get; }
public Type[] Types { get; } = Array.Empty<Type>();

public MissingRecordException(FormKey formKey, Type type)
{
FormKey = formKey;
Type = type;
}

public MissingRecordException(string editorID, Type type)
{
EditorID = editorID;
Type = type;
}

public MissingRecordException(FormKey formKey, Type[] types)
{
FormKey = formKey;
Type = types.FirstOrDefault();
Types = types;
}

public MissingRecordException(string editorID, Type[] types)
{
EditorID = editorID;
Type = types.FirstOrDefault();
Types = types;
}

public override string ToString()
{
if (Types.Length == 0)
{
if (Type != null)
{
return $"{nameof(MissingRecordException)} {FormKey?.ToString() ?? EditorID}<{Type}>: {this.Message} {this.InnerException}{this.StackTrace}";
}
else
{
return $"{nameof(MissingRecordException)} {FormKey?.ToString() ?? EditorID}: {this.Message} {this.InnerException}{this.StackTrace}";
}
}
else
{
return $"{nameof(MissingRecordException)} {FormKey?.ToString() ?? EditorID}<{Type} (+{Types.Length - 1})>: {this.Message} {this.InnerException}{this.StackTrace}";
}
}
}
}
10 changes: 7 additions & 3 deletions Mutagen.Bethesda.Core/Extensions/DuplicateFromMixIn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,13 @@ public static class DuplicateFromMixIn
// Compile list of things to duplicate
HashSet<FormLinkInformation> identifiedLinks = new();
HashSet<FormKey> passedLinks = new();
var implicits = Implicits.Get(modToDuplicateInto.GameRelease);

void AddAllLinks(FormLinkInformation link)
{
if (link.FormKey.IsNull || !passedLinks.Add(link.FormKey)) return;
if (link.FormKey.IsNull) return;
if (!passedLinks.Add(link.FormKey)) return;
if (implicits.RecordFormKeys.Contains(link.FormKey)) return;

if (link.FormKey.ModKey == modKeyToDuplicateFrom)
{
Expand All @@ -90,11 +93,12 @@ void AddAllLinks(FormLinkInformation link)

if (!linkCache.TryResolve(link.FormKey, link.Type, out var linkRec))
{
throw new KeyNotFoundException($"Could not locate record to make self contained: {link.FormKey}");
return;
}

foreach (var containedLink in linkRec.ContainedFormLinks)
{
if (containedLink.FormKey.ModKey != modKeyToDuplicateFrom) continue;
AddAllLinks(containedLink);
}
}
Expand All @@ -113,7 +117,7 @@ void AddAllLinks(FormLinkInformation link)
{
if (!linkCache.TryResolveContext(identifiedRec.FormKey, identifiedRec.Type, out var rec))
{
throw new KeyNotFoundException($"Coult not locate record to make self contained: {identifiedRec}");
throw new KeyNotFoundException($"Could not locate record to make self contained: {identifiedRec}");
}

var dup = rec.DuplicateIntoAsNewRecord(modToDuplicateInto, rec.Record.EditorID);
Expand Down
24 changes: 12 additions & 12 deletions Mutagen.Bethesda.Core/Extensions/FormLinkListMixIn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,65 +8,65 @@ namespace Mutagen.Bethesda
{
public static class FormLinkListMixIn
{
public static void Add<TMajor>(this IList<IFormLink<TMajor>> list, FormKey formKey)
public static void Add<TMajor>(this IList<IFormLinkGetter<TMajor>> list, FormKey formKey)
where TMajor : class, IMajorRecordCommonGetter
{
list.Add(new FormLink<TMajor>(formKey));
}

public static void AddRange<TMajor>(this IList<IFormLink<TMajor>> list, IEnumerable<FormKey> formKeys)
public static void AddRange<TMajor>(this IList<IFormLinkGetter<TMajor>> list, IEnumerable<FormKey> formKeys)
where TMajor : class, IMajorRecordCommonGetter
{
list.AddRange(formKeys.Select(formKey => (IFormLink<TMajor>)new FormLink<TMajor>(formKey)));
list.AddRange(formKeys.Select(formKey => (IFormLinkGetter<TMajor>)new FormLink<TMajor>(formKey)));
}

public static void Remove<TMajor>(this IList<IFormLink<TMajor>> list, FormKey formKey)
public static void Remove<TMajor>(this IList<IFormLinkGetter<TMajor>> list, FormKey formKey)
where TMajor : class, IMajorRecordCommonGetter
{
list.Remove(new FormLink<TMajor>(formKey));
}

public static void Remove<TMajor>(this IList<IFormLink<TMajor>> list, IEnumerable<FormKey> formKeys)
public static void Remove<TMajor>(this IList<IFormLinkGetter<TMajor>> list, IEnumerable<FormKey> formKeys)
where TMajor : class, IMajorRecordCommonGetter
{
list.Remove(formKeys.Select(formKey => (IFormLink<TMajor>)new FormLink<TMajor>(formKey)));
list.Remove(formKeys.Select(formKey => (IFormLinkGetter<TMajor>)new FormLink<TMajor>(formKey)));
}

public static void Add<TMajor, TMajorAdd>(this IList<IFormLink<TMajor>> list, TMajorAdd rec)
public static void Add<TMajor, TMajorAdd>(this IList<IFormLinkGetter<TMajor>> list, TMajorAdd rec)
where TMajor : class, IMajorRecordCommonGetter
where TMajorAdd : class, TMajor
{
list.Add(new FormLink<TMajor>(rec.FormKey));
}

public static void AddRange<TMajor, TMajorAdd>(this IList<IFormLink<TMajor>> list, IEnumerable<TMajorAdd> recs)
public static void AddRange<TMajor, TMajorAdd>(this IList<IFormLinkGetter<TMajor>> list, IEnumerable<TMajorAdd> recs)
where TMajor : class, IMajorRecordCommonGetter
where TMajorAdd : class, TMajor
{
list.AddRange(recs.Select(rec => rec.FormKey));
}

public static void Remove<TMajor, TMajorRem>(this IList<IFormLink<TMajor>> list, TMajorRem rec)
public static void Remove<TMajor, TMajorRem>(this IList<IFormLinkGetter<TMajor>> list, TMajorRem rec)
where TMajor : class, IMajorRecordCommonGetter
where TMajorRem : class, TMajor
{
list.Remove(new FormLink<TMajor>(rec.FormKey));
}

public static void Remove<TMajor, TMajorRem>(this IList<IFormLink<TMajor>> list, IEnumerable<TMajorRem> recs)
public static void Remove<TMajor, TMajorRem>(this IList<IFormLinkGetter<TMajor>> list, IEnumerable<TMajorRem> recs)
where TMajor : class, IMajorRecordCommonGetter
where TMajorRem : class, TMajor
{
list.Remove(recs.Select(rec => rec.FormKey));
}

public static bool Contains<TMajor>(this IReadOnlyList<IFormLink<TMajor>> list, FormKey formKey)
public static bool Contains<TMajor>(this IReadOnlyList<IFormLinkGetter<TMajor>> list, FormKey formKey)
where TMajor : class, IMajorRecordCommonGetter
{
return list.Any(f => f.FormKey == formKey);
}

public static bool Contains<TMajor, TMajorRem>(this IReadOnlyList<IFormLink<TMajor>> list, TMajorRem rec)
public static bool Contains<TMajor, TMajorRem>(this IReadOnlyList<IFormLinkGetter<TMajor>> list, TMajorRem rec)
where TMajor : class, IMajorRecordCommonGetter
where TMajorRem : class, TMajor
{
Expand Down
128 changes: 125 additions & 3 deletions Mutagen.Bethesda.Core/Extensions/FormLinkMixIn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,40 @@ public static class FormLinkMixIn
/// available. This particular extension function shouldn't need an explicitly defined generic
/// when calling it. It only works with non-abstract class types, though.
/// </summary>
public static FormLink<TGetter> AsLink<TGetter>(this IMapsToGetter<TGetter> rec)
public static IFormLink<TGetter> AsLink<TGetter>(this IMapsToGetter<TGetter> rec)
where TGetter : class, IMajorRecordCommonGetter
{
return new FormLink<TGetter>(rec.FormKey);
}

/// <summary>
/// Mix in to facilitate converting to FormLinks from interfaces where implicit operators aren't
/// available. This particular extension function shouldn't need an explicitly defined generic
/// when calling it. It only works with non-abstract class types, though.
/// </summary>
public static IFormLinkGetter<TGetter> AsLinkGetter<TGetter>(this IMapsToGetter<TGetter> rec)
where TGetter : class, IMajorRecordCommonGetter
{
return new FormLink<TGetter>(rec.FormKey);
}

/// <summary>
/// Mix in to facilitate converting to FormLinks from interfaces where implicit operators aren't
/// available. This particular extension function shouldn't need an explicitly defined generic
/// when calling it. It only works with non-abstract class types, though.
/// </summary>
public static IFormLink<TGetter> AsLink<TGetter>(this TGetter rec)
where TGetter : class, IMajorRecordCommonGetter
{
return new FormLink<TGetter>(rec.FormKey);
}

/// <summary>
/// Mix in to facilitate converting to FormLinks from interfaces where implicit operators aren't
/// available. This particular extension function shouldn't need an explicitly defined generic
/// when calling it. It only works with non-abstract class types, though.
/// </summary>
public static IFormLinkGetter<TGetter> AsLinkGetter<TGetter>(this TGetter rec)
where TGetter : class, IMajorRecordCommonGetter
{
return new FormLink<TGetter>(rec.FormKey);
Expand All @@ -24,13 +57,102 @@ public static FormLink<TGetter> AsLink<TGetter>(this IMapsToGetter<TGetter> rec)
/// available. This particular extension function needs an explicitly defined generic
/// when calling it, as it doesn't know what link type it should convert to automatically.
/// </summary>
public static FormLink<TGetter> AsLink<TGetter>(this IMajorRecordCommonGetter rec)
public static IFormLink<TGetter> AsLink<TGetter>(this IMajorRecordCommonGetter rec)
where TGetter : class, IMajorRecordCommonGetter
{
return new FormLink<TGetter>(rec.FormKey);
}

public static bool Contains<TGetter>(this IReadOnlyCollection<IFormLink<TGetter>> coll, TGetter record)
/// <summary>
/// Mix in to facilitate converting to FormLinks from interfaces where implicit operators aren't
/// available. This particular extension function needs an explicitly defined generic
/// when calling it, as it doesn't know what link type it should convert to automatically.
/// </summary>
public static IFormLinkGetter<TGetter> AsLinkGetter<TGetter>(this IMajorRecordCommonGetter rec)
where TGetter : class, IMajorRecordCommonGetter
{
return new FormLink<TGetter>(rec.FormKey);
}

/// <summary>
/// Mix in to facilitate converting to FormLinks from interfaces where implicit operators aren't
/// available. This particular extension function shouldn't need an explicitly defined generic
/// when calling it. It only works with non-abstract class types, though.
/// </summary>
public static IFormLinkNullable<TGetter> AsNullableLink<TGetter>(this IMapsToGetter<TGetter> rec)
where TGetter : class, IMajorRecordCommonGetter
{
return new FormLinkNullable<TGetter>(rec.FormKey);
}

/// <summary>
/// Mix in to facilitate converting to FormLinks from interfaces where implicit operators aren't
/// available. This particular extension function shouldn't need an explicitly defined generic
/// when calling it. It only works with non-abstract class types, though.
/// </summary>
public static IFormLinkNullableGetter<TGetter> AsNullableLinkGetter<TGetter>(this IMapsToGetter<TGetter> rec)
where TGetter : class, IMajorRecordCommonGetter
{
return new FormLinkNullable<TGetter>(rec.FormKey);
}

/// <summary>
/// Mix in to facilitate converting to FormLinks from interfaces where implicit operators aren't
/// available. This particular extension function shouldn't need an explicitly defined generic
/// when calling it. It only works with non-abstract class types, though.
/// </summary>
public static IFormLinkNullable<TGetter> AsNullableLink<TGetter>(this TGetter rec)
where TGetter : class, IMajorRecordCommonGetter
{
return new FormLinkNullable<TGetter>(rec.FormKey);
}

/// <summary>
/// Mix in to facilitate converting to FormLinks from interfaces where implicit operators aren't
/// available. This particular extension function shouldn't need an explicitly defined generic
/// when calling it. It only works with non-abstract class types, though.
/// </summary>
public static IFormLinkNullableGetter<TGetter> AsNullableLinkGetter<TGetter>(this TGetter rec)
where TGetter : class, IMajorRecordCommonGetter
{
return new FormLinkNullable<TGetter>(rec.FormKey);
}

/// <summary>
/// Mix in to facilitate converting to FormLinks from interfaces where implicit operators aren't
/// available. This particular extension function needs an explicitly defined generic
/// when calling it, as it doesn't know what link type it should convert to automatically.
/// </summary>
public static IFormLinkNullable<TGetter> AsNullableLink<TGetter>(this IMajorRecordCommonGetter rec)
where TGetter : class, IMajorRecordCommonGetter
{
return new FormLinkNullable<TGetter>(rec.FormKey);
}

/// <summary>
/// Mix in to facilitate converting to FormLinks from interfaces where implicit operators aren't
/// available. This particular extension function needs an explicitly defined generic
/// when calling it, as it doesn't know what link type it should convert to automatically.
/// </summary>
public static IFormLinkNullableGetter<TGetter> AsNullableLinkGetter<TGetter>(this IMajorRecordCommonGetter rec)
where TGetter : class, IMajorRecordCommonGetter
{
return new FormLinkNullable<TGetter>(rec.FormKey);
}

public static IFormLinkGetter<TGetter> AsGetter<TGetter>(this IFormLink<TGetter> link)
where TGetter : class, IMajorRecordCommonGetter
{
return link;
}

public static IFormLinkNullableGetter<TGetter> AsGetter<TGetter>(this IFormLinkNullable<TGetter> link)
where TGetter : class, IMajorRecordCommonGetter
{
return link;
}

public static bool Contains<TGetter>(this IReadOnlyCollection<IFormLinkGetter<TGetter>> coll, TGetter record)
where TGetter : class, IMajorRecordCommonGetter
{
return coll.Contains(new FormLink<TGetter>(record.FormKey));
Expand Down

0 comments on commit 3476051

Please sign in to comment.