Skip to content

Commit

Permalink
Support .NET 8
Browse files Browse the repository at this point in the history
  • Loading branch information
melanchall committed Dec 18, 2023
1 parent 01a2300 commit dfa4550
Show file tree
Hide file tree
Showing 16 changed files with 62 additions and 36 deletions.
2 changes: 1 addition & 1 deletion Docs/articles/dev/Support.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Things to pay attention for are:
3. Provide your code (as text, not as a screenshot!) and point me to the place there where the error occurred or where you need to do something.
4. What is your operating system?
5. What version of the library do you use?
6. Use proper MIDI terminology. Official MIDI specification can be found on the [midi.org](https://midi.org/specifications/midi1-specifications/m1-v4-2-1-midi-1-0-detailed-specification-96-1-4).
6. Use proper MIDI terminology. Official MIDI specification can be found on the [midi.org](https://www.midi.org/specifications/midi1-specifications/midi-1-0-core-specifications/midi-1-0-detailed-specification-2).
7. Use formatting for your messages (especially for code blocks):
* on GitHub use [Markdown](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax);
* on emails use formatting provided by your mail client.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net48;net7.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net48;net8.0</TargetFrameworks>
<OutputType>Library</OutputType>
<Configurations>Debug;Release;Coverage;DebugTest;ReleaseTest</Configurations>
<SignAssembly>true</SignAssembly>
Expand Down
2 changes: 1 addition & 1 deletion DryWetMidi.Tests/Melanchall.DryWetMidi.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net48;net7.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net48;net8.0</TargetFrameworks>
<OutputType>Library</OutputType>
<Configurations>Debug;Release;Coverage;DebugTest;ReleaseTest</Configurations>
<SignAssembly>true</SignAssembly>
Expand Down
62 changes: 40 additions & 22 deletions DryWetMidi/Tools/Splitter/MidiFileSlicer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ private sealed class TimedEventsHolder : IDisposable
{
#region Fields

private readonly IEnumerator<TimedEvent> _enumerator;

private bool _disposed = false;

#endregion
Expand All @@ -22,22 +24,36 @@ private sealed class TimedEventsHolder : IDisposable

public TimedEventsHolder(IEnumerator<TimedEvent> timedEventsEnumerator)
{
Enumerator = timedEventsEnumerator;
Enumerator.MoveNext();
_enumerator = timedEventsEnumerator;
CanBeEnumerated = _enumerator.MoveNext();
}

#endregion

#region Properties

public IEnumerator<TimedEvent> Enumerator { get; }
public bool CanBeEnumerated { get; private set; }

public List<TimedEvent> EventsToCopyToNextPart { get; } = new List<TimedEvent>();

public List<TimedEvent> EventsToStartNextPart { get; } = new List<TimedEvent>();

#endregion

#region Methods

public bool MoveToNextEvent()
{
return CanBeEnumerated = _enumerator.MoveNext();
}

public TimedEvent GetCurrentEvent()
{
return _enumerator.Current;
}

#endregion

#region IDisposable

private void Dispose(bool disposing)
Expand All @@ -46,7 +62,7 @@ private void Dispose(bool disposing)
return;

if (disposing)
Enumerator.Dispose();
_enumerator.Dispose();

_disposed = true;
}
Expand Down Expand Up @@ -142,7 +158,7 @@ private MidiFileSlicer(TimeDivision timeDivision, IEnumerator<TimedEvent>[] time

#region Properties

public bool AllEventsProcessed => _timedEventsHolders.All(c => !c.EventsToStartNextPart.Any() && c.Enumerator.Current == null);
public bool AllEventsProcessed => _timedEventsHolders.All(c => !c.EventsToStartNextPart.Any() && !c.CanBeEnumerated);

#endregion

Expand Down Expand Up @@ -191,7 +207,6 @@ private IEnumerable<IEnumerable<TimedEvent>> GetNextTimedEvents(
{
var timedEventsHolder = _timedEventsHolders[i];

var timedEventsEnumerator = timedEventsHolder.Enumerator;
var eventsToCopyToNextPart = timedEventsHolder.EventsToCopyToNextPart;
var eventsToStartNextPart = timedEventsHolder.EventsToStartNextPart;

Expand All @@ -202,29 +217,32 @@ private IEnumerable<IEnumerable<TimedEvent>> GetNextTimedEvents(
eventsToStartNextPart,
out newEventsStartIndex);

do
if (timedEventsHolder.CanBeEnumerated)
{
var timedEvent = timedEventsEnumerator.Current;
if (timedEvent == null)
break;
do
{
var timedEvent = timedEventsHolder.GetCurrentEvent();
if (timedEvent == null)
break;

var time = timedEvent.Time;
if (time > endTime)
break;
var time = timedEvent.Time;
if (time > endTime)
break;

if (time == endTime)
{
if (!TryToMoveEdgeNoteOffsToPreviousPart(timedEvent, takenTimedEvents))
eventsToStartNextPart.Add(timedEvent);
if (time == endTime)
{
if (!TryToMoveEdgeNoteOffsToPreviousPart(timedEvent, takenTimedEvents))
eventsToStartNextPart.Add(timedEvent);

continue;
}
continue;
}

UpdateEventsToCopyToNextPart(eventsToCopyToNextPart, timedEvent);
UpdateEventsToCopyToNextPart(eventsToCopyToNextPart, timedEvent);

takenTimedEvents.Add(timedEvent);
takenTimedEvents.Add(timedEvent);
}
while (timedEventsHolder.MoveToNextEvent());
}
while (timedEventsEnumerator.MoveNext());

isPartEmpty &= newEventsStartIndex >= takenTimedEvents.Count;

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

DryWetMIDI is the .NET library to work with MIDI data and MIDI devices. It allows:

* Read, write and create [Standard MIDI Files (SMF)](https://www.midi.org/specifications/category/smf-specifications). It is also possible to read [RMID](https://www.loc.gov/preservation/digital/formats/fdd/fdd000120.shtml) files where SMF wrapped to RIFF chunk. You can easily catch specific error when reading or writing MIDI file since all possible errors in a MIDI file are presented as separate exception classes.
* Read, write and create [Standard MIDI Files (SMF)](https://www.midi.org/specifications/file-format-specifications/standard-midi-files). It is also possible to read [RMID](https://www.loc.gov/preservation/digital/formats/fdd/fdd000120.shtml) files where SMF wrapped to RIFF chunk. You can easily catch specific error when reading or writing MIDI file since all possible errors in a MIDI file are presented as separate exception classes.
* [Send](https://melanchall.github.io/drywetmidi/articles/devices/Output-device.html) MIDI events to/[receive](https://melanchall.github.io/drywetmidi/articles/devices/Input-device.html) them from MIDI devices, [play](https://melanchall.github.io/drywetmidi/articles/playback/Overview.html) MIDI data and [record](https://melanchall.github.io/drywetmidi/articles/recording/Overview.html) it. This APIs support Windows and macOS.
* Finely adjust process of reading and writing. It allows, for example, to read corrupted files and repair them, or build MIDI file validators.
* Implement [custom meta events](https://melanchall.github.io/drywetmidi/articles/custom-data-structures/Custom-meta-events.html) and [custom chunks](https://melanchall.github.io/drywetmidi/articles/custom-data-structures/Custom-chunks.html) that can be written to and read from MIDI files.
Expand Down
2 changes: 1 addition & 1 deletion Resources/CI/Templates/job-build-utility.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- task: ArchiveFiles@2
displayName: Archive utility
inputs:
rootFolderOrFile: 'Utilities\${{ parameters.projectName }}\bin\$(BuildConfiguration)\net7.0\${{ rid }}\publish'
rootFolderOrFile: 'Utilities\${{ parameters.projectName }}\bin\$(BuildConfiguration)\$(Build.Framework.Net.Tfm)\${{ rid }}\publish'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)\Utility\Melanchall.${{ parameters.projectName }}.$(LibraryVersion)-${{ rid }}.zip'
Expand Down
8 changes: 8 additions & 0 deletions Resources/CI/test-net-selfcontained-package-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ stages:
parameters:
enabled: contains(variables.vmImage, 'macos')

- task: PowerShell@2
displayName: Restore NuGet packages
inputs:
targetType: 'inline'
script: |
$path = Resolve-Path 'Resources\PackageIntegrationTestUtilities\DwmNetSelfContainedConsoleApp\DwmNetSelfContainedConsoleApp\DwmNetSelfContainedConsoleApp.csproj'
dotnet restore "$path" -s "https://api.nuget.org/v3/index.json"
- task: PowerShell@2
displayName: Add package to the project
inputs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Utilities/Common/Melanchall.Common.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<PublishSingleFile>true</PublishSingleFile>
<PublishTrimmed>true</PublishTrimmed>
<RuntimeIdentifiers>win-x64;osx-x64</RuntimeIdentifiers>
Expand Down
2 changes: 1 addition & 1 deletion Utilities/SendMidiData/Melanchall.SendMidiData.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<PublishSingleFile>true</PublishSingleFile>
<PublishTrimmed>true</PublishTrimmed>
<RuntimeIdentifiers>win-x64;osx-x64</RuntimeIdentifiers>
Expand Down

0 comments on commit dfa4550

Please sign in to comment.