Skip to content

Commit

Permalink
.NET 9 Migration (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
wbaldoumas authored Nov 23, 2024
1 parent 6a4ebf2 commit d5c38ef
Show file tree
Hide file tree
Showing 29 changed files with 112 additions and 200 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,17 @@ dotnet_diagnostic.SA1118.severity = none
# force static members to appear before non-static
dotnet_diagnostic.SA1204.severity = none

# style warnings
dotnet_diagnostic.IDE0008.severity = none
dotnet_diagnostic.IDE0021.severity = none
dotnet_diagnostic.IDE0022.severity = none
dotnet_diagnostic.IDE0024.severity = none
dotnet_diagnostic.IDE0027.severity = none
dotnet_diagnostic.IDE0046.severity = none
dotnet_diagnostic.IDE0060.severity = none
dotnet_diagnostic.IDE0130.severity = none
dotnet_diagnostic.IDE0055.severity = none

# force abstraction over implementation
dotnet_diagnostic.MA0016.severity = none
csharp_using_directive_placement = outside_namespace:silent
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: 🔨 set up .net
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x

- name: 🧪 run tests
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand Down
8 changes: 5 additions & 3 deletions src/BaroquenMelody.App/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ public App(IThemeProvider themeProvider)

_themeProvider = themeProvider;

_themeProvider.IsDarkMode = Preferences.Default.Get("IsDarkMode", true);
_themeProvider.IsDarkMode = Preferences.Default.Get("IsDarkMode", defaultValue: true);

MainPage = new MainPage();
MainPage.Title = "Baroquen Melody";
MainPage = new MainPage
{
Title = "Baroquen Melody"
};
}

protected override Window CreateWindow(IActivationState? activationState)
Expand Down
2 changes: 2 additions & 0 deletions src/BaroquenMelody.App/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
using BaroquenMelody.Library.Midi;
using CommunityToolkit.Maui;
using Microsoft.AspNetCore.Components.WebView.Maui;
#pragma warning disable IDE0005 // Using directive is unnecessary.
using Microsoft.Extensions.Logging;
#pragma warning restore IDE0005 // Using directive is unnecessary.

namespace BaroquenMelody.App;

Expand Down
7 changes: 1 addition & 6 deletions src/BaroquenMelody.App/Platforms/Android/MainApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@
namespace BaroquenMelody.App;

[Application]
public class MainApplication : MauiApplication
public class MainApplication(IntPtr handle, JniHandleOwnership ownership) : MauiApplication(handle, ownership)
{
public MainApplication(IntPtr handle, JniHandleOwnership ownership)
: base(handle, ownership)
{
}

protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,7 @@ private static void PossiblyResizeChildOfContent()
heightDifference = usableHeightSansKeyboard - usableHeightNow;
}

if (heightDifference > usableHeightSansKeyboard / 4)
{
_frameLayoutParams!.Height = usableHeightSansKeyboard - heightDifference;
}
else
{
_frameLayoutParams!.Height = usableHeightNow;
}
_frameLayoutParams!.Height = heightDifference > usableHeightSansKeyboard / 4 ? usableHeightSansKeyboard - heightDifference : usableHeightNow;
}

_mChildOfContent!.RequestLayout();
Expand Down
10 changes: 1 addition & 9 deletions src/BaroquenMelody.Library/Choices/ChordChoice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,7 @@ public IList<NoteChoice> NoteChoices
init { _noteChoices = [.. value.OrderBy(static noteChoice => noteChoice.Instrument)]; }
}

public bool Equals(ChordChoice? other)
{
if (other is null)
{
return false;
}

return ReferenceEquals(this, other) || NoteChoices.SequenceEqual(other.NoteChoices);
}
public bool Equals(ChordChoice? other) => other is not null && (ReferenceEquals(this, other) || NoteChoices.SequenceEqual(other.NoteChoices));

public override int GetHashCode()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public SoloChordChoiceRepository(CompositionConfiguration compositionConfigurati
);
}

_noteChoices = noteChoiceGenerator.GenerateNoteChoices(compositionConfiguration.Instruments[0]).ToList();
_noteChoices = [.. noteChoiceGenerator.GenerateNoteChoices(compositionConfiguration.Instruments[0])];
}

public BigInteger Count => _noteChoices.Count;
Expand Down
25 changes: 2 additions & 23 deletions src/BaroquenMelody.Library/Domain/BaroquenChord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,7 @@ public void ResetOrnamentation(MusicalTimeSpan defaultTimeSpan)
/// </summary>
/// <param name="other">The other <see cref="BaroquenChord"/> to compare against.</param>
/// <returns>Whether the <see cref="BaroquenChord"/> is equal to the other <see cref="BaroquenChord"/>.</returns>
public bool Equals(BaroquenChord? other)
{
if (other is null)
{
return false;
}

return ReferenceEquals(this, other) || Notes.SequenceEqual(other.Notes);
}
public bool Equals(BaroquenChord? other) => other is not null && (ReferenceEquals(this, other) || Notes.SequenceEqual(other.Notes));

/// <summary>
/// Determines if the <see cref="BaroquenChord"/> is equal to another object.
Expand All @@ -75,20 +67,7 @@ public bool Equals(BaroquenChord? other)
/// <param name="chord">The first <see cref="BaroquenChord"/> to compare.</param>
/// <param name="otherChord">The second <see cref="BaroquenChord"/> to compare.</param>
/// <returns>Whether the <see cref="BaroquenChord"/> is equal to the other <see cref="BaroquenChord"/>.</returns>
public static bool operator ==(BaroquenChord? chord, BaroquenChord? otherChord)
{
if (ReferenceEquals(chord, otherChord))
{
return true;
}

if (chord is null || otherChord is null)
{
return false;
}

return chord.Equals(otherChord);
}
public static bool operator ==(BaroquenChord? chord, BaroquenChord? otherChord) => ReferenceEquals(chord, otherChord) || (chord is not null && otherChord is not null && chord.Equals(otherChord));

/// <summary>
/// Determines if the <see cref="BaroquenChord"/> is not equal to another <see cref="BaroquenChord"/>.
Expand Down
15 changes: 1 addition & 14 deletions src/BaroquenMelody.Library/Domain/BaroquenNote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,20 +125,7 @@ public bool Equals(BaroquenNote? other)
/// <param name="note">The first <see cref="BaroquenNote"/> to compare.</param>
/// <param name="otherNote">The second <see cref="BaroquenNote"/> to compare.</param>
/// <returns>Whether the <see cref="BaroquenNote"/> is equal to the other <see cref="BaroquenNote"/>.</returns>
public static bool operator ==(BaroquenNote? note, BaroquenNote? otherNote)
{
if (ReferenceEquals(note, otherNote))
{
return true;
}

if (note is null || otherNote is null)
{
return false;
}

return note.Equals(otherNote);
}
public static bool operator ==(BaroquenNote? note, BaroquenNote? otherNote) => ReferenceEquals(note, otherNote) || (note is not null && otherNote is not null && note.Equals(otherNote));

/// <summary>
/// Determines if the <see cref="BaroquenNote"/> is not equal to another <see cref="BaroquenNote"/>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,9 @@ public void Process(DynamicsApplicationItem item)
var instrumentConfiguration = configuration.InstrumentConfigurationsByInstrument[item.Instrument];
var note = item.CurrentBeat[item.Instrument];

double velocity;

if (instrumentConfiguration.HasSizeableVelocityRange)
{
velocity = instrumentConfiguration.MinVelocity + instrumentConfiguration.VelocityRange * velocityRangeTarget;
}
else
{
velocity = instrumentConfiguration.MaxVelocity;
}
var velocity = instrumentConfiguration.HasSizeableVelocityRange
? instrumentConfiguration.MinVelocity + instrumentConfiguration.VelocityRange * velocityRangeTarget
: instrumentConfiguration.MaxVelocity;

note.Velocity = new SevenBitNumber(Convert.ToByte(velocity));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,9 @@ internal static class NoteMotionExtensions
/// <param name="previousNote">The first note.</param>
/// <param name="currentNote">The second note.</param>
/// <returns>A <see cref="NoteMotion"/> representing the motion between the two notes.</returns>
public static NoteMotion FromNotes(Note previousNote, Note currentNote)
{
if (previousNote == currentNote)
{
return NoteMotion.Oblique;
}

return previousNote.NoteNumber > currentNote.NoteNumber ? NoteMotion.Descending : NoteMotion.Ascending;
}
public static NoteMotion FromNotes(Note previousNote, Note currentNote) => previousNote == currentNote
? NoteMotion.Oblique
: previousNote.NoteNumber > currentNote.NoteNumber
? NoteMotion.Descending
: NoteMotion.Ascending;
}
Loading

0 comments on commit d5c38ef

Please sign in to comment.