Skip to content

Commit

Permalink
Unify single main project in .net 8
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBoxyBear committed Jan 3, 2024
1 parent b435f09 commit 2fe3ce5
Show file tree
Hide file tree
Showing 323 changed files with 8,315 additions and 147 deletions.
45 changes: 7 additions & 38 deletions ChartTools.Tests/AlternatingTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using ChartTools.Extensions.Collections;
using ChartTools.Extensions.Collections.Alternating;

using Microsoft.VisualStudio.TestTools.UnitTesting;

Expand All @@ -7,59 +7,28 @@ namespace ChartTools.Tests;
[TestClass]
public class SerialAlternatingTests
{
static readonly byte[] testArrayA = new byte[] { 1, 6, 2 };
static readonly byte[] testArrayB = new byte[] { 3, 5, 6 };
static readonly byte[] testArrayA = [ 1, 6, 2 ];
static readonly byte[] testArrayB = [ 3, 5, 6 ];
const string expected = "1 3 6 5 2 6";

[TestMethod] public void CreateEnumerableNull() => Assert.ThrowsException<ArgumentNullException>(() => new SerialAlternatingEnumerable<byte>(null!));
[TestMethod] public void CreateEnumerableEmpty() => Assert.ThrowsException<ArgumentException>(() => new SerialAlternatingEnumerable<byte>());

[TestMethod] public void CreateEnumeratorNull() => Assert.ThrowsException<ArgumentNullException>(() => new SerialAlternatingEnumerator<byte>(null!));
[TestMethod] public void CreateEnumeratorEmpty() => Assert.ThrowsException<ArgumentException>(() => new SerialAlternatingEnumerator<byte>());

[TestMethod] public void EnumerateFromEnumerable() => Assert.AreEqual(expected, Formatting.FormatCollection(new SerialAlternatingEnumerable<byte>(testArrayA, testArrayB)));

[TestMethod] public void EnumerateFromEnumertor()
{
var enumerator = new SerialAlternatingEnumerator<byte>(testArrayA.AsEnumerable().GetEnumerator(), testArrayB.AsEnumerable().GetEnumerator());
var output = new List<byte>(6);

for (int i = 0; i < 6; i++)
{
Assert.IsTrue(enumerator.MoveNext());
output.Add(enumerator.Current);
}

Assert.AreEqual(expected, Formatting.FormatCollection(output));
}
[TestMethod] public void Enumerate() => Assert.AreEqual(expected, Formatting.FormatCollection(new SerialAlternatingEnumerable<byte>(testArrayA, testArrayB)));
}

[TestClass]
public class OrderedAlternatingTests
{
static readonly Func<byte, byte> keyGetter = n => n;
static readonly byte[] testArrayA = new byte[] { 1, 6, 2 };
static readonly byte[] testArrayB = new byte[] { 3, 5, 6 };
static readonly byte[] testArrayA = [1, 6, 2];
static readonly byte[] testArrayB = [3, 5, 6];
const string expected = "1 3 5 6 2 6";

[TestMethod] public void CreateEnumerableNullKeyGetter() => Assert.ThrowsException<ArgumentNullException>(() => new OrderedAlternatingEnumerable<byte, byte>(null!, null!));

[TestMethod] public void CreateEnumerableNullEnumerables() => Assert.ThrowsException<ArgumentNullException>(() => new OrderedAlternatingEnumerable<byte, byte>(null!, null!));
[TestMethod] public void CreateEnumerableEmptyEnumerables() => Assert.ThrowsException<ArgumentException>(() => new OrderedAlternatingEnumerable<byte, byte>(keyGetter));

[TestMethod] public void EnumerateFromEnumerable() => Assert.AreEqual(expected, Formatting.FormatCollection(new OrderedAlternatingEnumerable<byte, byte>(keyGetter, testArrayA, testArrayB)));

[TestMethod] public void EnumerateFromEnumertor()
{
var enumerator = new OrderedAlternatingEnumerator<byte, byte>(keyGetter, testArrayA.AsEnumerable().GetEnumerator(), testArrayB.AsEnumerable().GetEnumerator());
var output = new List<byte>(6);

for (int i = 0; i < 6; i++)
{
Assert.IsTrue(enumerator.MoveNext());
output.Add(enumerator.Current);
}

Assert.AreEqual(expected, Formatting.FormatCollection(output));
}
[TestMethod] public void Enumerate() => Assert.AreEqual(expected, Formatting.FormatCollection(new OrderedAlternatingEnumerable<byte, byte>(keyGetter, testArrayA, testArrayB)));
}
15 changes: 8 additions & 7 deletions ChartTools.Tests/ChartTools.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>preview</LangVersion>
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
Expand All @@ -10,16 +10,17 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Melanchall.DryWetMidi.Nativeless" Version="6.1.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.0.2" />
<PackageReference Include="MSTest.TestFramework" Version="3.0.2" />
<PackageReference Include="coverlet.collector" Version="3.2.0">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<Import Project="..\source\source.projitems" Label="Shared" />
<ItemGroup>
<ProjectReference Include="..\ChartTools\ChartTools.csproj" />
</ItemGroup>

</Project>
6 changes: 3 additions & 3 deletions ChartTools.Tests/SystemExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ namespace ChartTools.Tests;
[TestClass]
public class SystemExtensionsTests
{
static readonly bool[] trueArray = new bool[] { true, true };
static readonly bool[] falseArray = new bool[] { false, false };
static readonly bool[] mixBoolArray = new bool[] { true, false };
static readonly bool[] trueArray = [true, true];
static readonly bool[] falseArray = [false, false];
static readonly bool[] mixBoolArray = [true, false];

[TestMethod] public void AllNoBools() => Assert.AreEqual(true, Array.Empty<bool>().All());
[TestMethod] public void AllNoFalse() => Assert.AreEqual(true, trueArray.All());
Expand Down
37 changes: 7 additions & 30 deletions ChartTools.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,9 @@ VisualStudioVersion = 17.0.31612.314
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ChartTools.Tests", "ChartTools.Tests\ChartTools.Tests.csproj", "{A5A22025-AFC9-49D2-A338-CAE8EA750E18}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "ChartTools", "source\ChartTools.shproj", "{54924BC3-4A10-45AD-AF3C-F17494E403E1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Net6", "Net6\Net6.csproj", "{965901B2-4DD8-4DAF-836F-A0DFF21DB9E4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Debug", "Debug\Debug.csproj", "{A309B8D1-538E-4C63-93B7-A56125B169E9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Docs", "Docs\Docs.csproj", "{B5A19C40-6CCD-48B2-827F-0D24B6271530}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Net7", "Net7\Net7.csproj", "{07D226A8-7464-4DE0-A384-A26F37153CDA}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChartTools", "ChartTools\ChartTools.csproj", "{487BDC85-A45E-4896-9F1F-1A8EC145BD19}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -27,38 +21,21 @@ Global
{A5A22025-AFC9-49D2-A338-CAE8EA750E18}.Docs|Any CPU.ActiveCfg = Docs|Any CPU
{A5A22025-AFC9-49D2-A338-CAE8EA750E18}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A5A22025-AFC9-49D2-A338-CAE8EA750E18}.Release|Any CPU.Build.0 = Release|Any CPU
{965901B2-4DD8-4DAF-836F-A0DFF21DB9E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{965901B2-4DD8-4DAF-836F-A0DFF21DB9E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{965901B2-4DD8-4DAF-836F-A0DFF21DB9E4}.Docs|Any CPU.ActiveCfg = Debug|Any CPU
{965901B2-4DD8-4DAF-836F-A0DFF21DB9E4}.Docs|Any CPU.Build.0 = Debug|Any CPU
{965901B2-4DD8-4DAF-836F-A0DFF21DB9E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{965901B2-4DD8-4DAF-836F-A0DFF21DB9E4}.Release|Any CPU.Build.0 = Release|Any CPU
{A309B8D1-538E-4C63-93B7-A56125B169E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A309B8D1-538E-4C63-93B7-A56125B169E9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A309B8D1-538E-4C63-93B7-A56125B169E9}.Docs|Any CPU.ActiveCfg = Docs|Any CPU
{A309B8D1-538E-4C63-93B7-A56125B169E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A309B8D1-538E-4C63-93B7-A56125B169E9}.Release|Any CPU.Build.0 = Release|Any CPU
{B5A19C40-6CCD-48B2-827F-0D24B6271530}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B5A19C40-6CCD-48B2-827F-0D24B6271530}.Docs|Any CPU.ActiveCfg = Release|Any CPU
{B5A19C40-6CCD-48B2-827F-0D24B6271530}.Docs|Any CPU.Build.0 = Release|Any CPU
{B5A19C40-6CCD-48B2-827F-0D24B6271530}.Release|Any CPU.ActiveCfg = Release|Any CPU
{07D226A8-7464-4DE0-A384-A26F37153CDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{07D226A8-7464-4DE0-A384-A26F37153CDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{07D226A8-7464-4DE0-A384-A26F37153CDA}.Docs|Any CPU.ActiveCfg = Debug|Any CPU
{07D226A8-7464-4DE0-A384-A26F37153CDA}.Docs|Any CPU.Build.0 = Debug|Any CPU
{07D226A8-7464-4DE0-A384-A26F37153CDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{07D226A8-7464-4DE0-A384-A26F37153CDA}.Release|Any CPU.Build.0 = Release|Any CPU
{487BDC85-A45E-4896-9F1F-1A8EC145BD19}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{487BDC85-A45E-4896-9F1F-1A8EC145BD19}.Debug|Any CPU.Build.0 = Debug|Any CPU
{487BDC85-A45E-4896-9F1F-1A8EC145BD19}.Docs|Any CPU.ActiveCfg = Debug|Any CPU
{487BDC85-A45E-4896-9F1F-1A8EC145BD19}.Docs|Any CPU.Build.0 = Debug|Any CPU
{487BDC85-A45E-4896-9F1F-1A8EC145BD19}.Release|Any CPU.ActiveCfg = Release|Any CPU
{487BDC85-A45E-4896-9F1F-1A8EC145BD19}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BBCCC1EF-9696-4588-8FA9-7924F6507D21}
EndGlobalSection
GlobalSection(SharedMSBuildProjectFiles) = preSolution
source\source.projitems*{07d226a8-7464-4de0-a384-a26f37153cda}*SharedItemsImports = 5
source\source.projitems*{54924bc3-4a10-45ad-af3c-f17494e403e1}*SharedItemsImports = 13
source\source.projitems*{965901b2-4dd8-4daf-836f-a0dff21db9e4}*SharedItemsImports = 5
source\source.projitems*{a5a22025-afc9-49d2-a338-cae8ea750e18}*SharedItemsImports = 5
EndGlobalSection
EndGlobal
13 changes: 13 additions & 0 deletions ChartTools/ChartTools.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Melanchall.DryWetMidi.Nativeless" Version="7.0.2" />
</ItemGroup>

</Project>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
63 changes: 63 additions & 0 deletions ChartTools/Events/EventExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using ChartTools.IO;
using ChartTools.IO.Chart;
using ChartTools.Extensions.Linq;
using ChartTools.Lyrics;

namespace ChartTools.Events;

/// <summary>
/// Provides additional methods for events.
/// </summary>
public static class EventExtensions
{
public static void ToFile(this IEnumerable<GlobalEvent> events, string path) => ExtensionHandler.Write(path, events, (".chart", (path, events) => ChartFile.ReplaceGlobalEvents(path, events)));
public static async Task ToFileAsync(this IEnumerable<GlobalEvent> events, string path, CancellationToken cancellationToken) => await ExtensionHandler.WriteAsync(path, events, (".chart", (path, events) => ChartFile.ReplaceGlobalEventsAsync(path, events, cancellationToken)));

/// <summary>
/// Gets the lyrics from an enumerable of <see cref="GlobalEvent"/>
/// </summary>
/// <returns>Enumerable of <see cref="Phrase"/></returns>
public static IEnumerable<Phrase> GetLyrics(this IEnumerable<GlobalEvent> globalEvents)
{
Phrase? phrase = null;

foreach (GlobalEvent globalEvent in globalEvents.OrderBy(e => e.Position))
switch (globalEvent.EventType)
{
// Change active phrase
case EventTypeHelper.Global.PhraseStart:
if (phrase is not null)
yield return phrase;

phrase = new Phrase(globalEvent.Position);
break;
// Add syllable to the active phrase using the event argument
case EventTypeHelper.Global.Lyric:
phrase?.Syllables.Add(new(globalEvent.Position - phrase.Position, VocalPitchValue.None) { RawText = globalEvent.Argument ?? string.Empty });
break;
// Set length of active phrase
case EventTypeHelper.Global.PhraseEnd:
if (phrase is not null)
phrase.LengthOverride = globalEvent.Position - phrase.Position;
break;
}

if (phrase is not null)
yield return phrase;
}
/// <summary>
/// Gets a set of <see cref="GlobalEvent"/> where phrase and lyric events are replaced with the events making up a set of <see cref="Phrase"/>.
/// </summary>
/// <returns>Enumerable of <see cref="GlobalEvent"/></returns>
public static IEnumerable<GlobalEvent> SetLyrics(this IEnumerable<GlobalEvent> events, IEnumerable<Phrase> lyrics)
{
IEnumerable<GlobalEvent>[] collections =
[
events.Where(e => !e.IsLyricEvent),
lyrics.SelectMany(p => p.ToGlobalEvents())
];

foreach (var globalEvent in collections.AlternateBy(i => i.Position))
yield return globalEvent;
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 2fe3ce5

Please sign in to comment.