Skip to content

Commit

Permalink
Merge pull request #7 from MikeMoolenaar/develop
Browse files Browse the repository at this point in the history
Release 1.1.0
  • Loading branch information
MikeMoolenaar authored Jan 13, 2024
2 parents 368d326 + 2222a62 commit 84fe4a4
Show file tree
Hide file tree
Showing 42 changed files with 1,307 additions and 1,071 deletions.
125 changes: 125 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
###############################
# Core EditorConfig Options #
###############################
root = true
# All files
[*]
indent_style = space

# XML project files
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
indent_size = 2

# XML config files
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
indent_size = 2

# Code files
[*.{cs,csx,vb,vbx}]
indent_size = 4
insert_final_newline = true
charset = utf-8
###############################
# .NET Coding Conventions #
###############################
[*.{cs,vb}]
# Organize usings
dotnet_sort_system_directives_first = true
# this. preferences
dotnet_style_qualification_for_field = false:warning
dotnet_style_qualification_for_property = false:warning
dotnet_style_qualification_for_method = false:warning
dotnet_style_qualification_for_event = false:warning
# Language keywords vs BCL types preferences
dotnet_style_predefined_type_for_locals_parameters_members = true:silent
dotnet_style_predefined_type_for_member_access = true:silent
# Parentheses preferences
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
# Modifier preferences
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
dotnet_style_readonly_field = true:suggestion
# Expression-level preferences
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:silent
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_auto_properties = true:silent
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
dotnet_style_prefer_conditional_expression_over_return = true:silent
###############################
# Naming Conventions #
###############################
# Style Definitions
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
# Use PascalCase for constant fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
dotnet_naming_symbols.constant_fields.applicable_kinds = field
dotnet_naming_symbols.constant_fields.applicable_accessibilities = *
dotnet_naming_symbols.constant_fields.required_modifiers = const
###############################
# C# Coding Conventions #
###############################
[*.cs]
# var preferences
csharp_style_var_for_built_in_types = true:silent
csharp_style_var_when_type_is_apparent = true:silent
csharp_style_var_elsewhere = true:silent
# Expression-bodied members
csharp_style_expression_bodied_methods = false:silent
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = true:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_accessors = true:silent
# Pattern matching preferences
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
# Null-checking preferences
csharp_style_throw_expression = true:suggestion
csharp_style_conditional_delegate_call = true:suggestion
# Modifier preferences
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion
# Expression-level preferences
csharp_prefer_braces = true:silent
csharp_style_deconstructed_variable_declaration = true:suggestion
csharp_prefer_simple_default_expression = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
###############################
# C# Formatting Rules #
###############################
# New line preferences
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_between_query_expression_clauses = true
# Indentation preferences
csharp_indent_case_contents = true
csharp_indent_switch_labels = true
csharp_indent_labels = flush_left
# Space preferences
csharp_space_after_cast = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_around_binary_operators = before_and_after
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_between_method_call_empty_parameter_list_parentheses = false
# Wrapping preferences
csharp_preserve_single_line_statements = true
csharp_preserve_single_line_blocks = true
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,25 @@ name: Build & test

on:
push:
branches: [ main ]
branches: [ main, develop ]
paths:
- 'MatroskaLib/**'
- 'MkvDefaultTrackChanger/**'
- 'TestMkvFiles/**'
- '.github/workflows/build-and-test.yml'
pull_request:
branches: [ main ]
branches: [ main, develop ]

jobs:
build-and-test:

runs-on: windows-latest

steps:
- uses: actions/checkout@v2
- uses: FedericoCarboni/setup-ffmpeg@v1
# - uses: actions/cache@v2
# with:
# path: ~/.nuget/packages
# key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
# restore-keys: |
# ${{ runner.os }}-nuget-
- name: Setup .NET
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v3
with:
dotnet-version: 5.0.x
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand Down
41 changes: 20 additions & 21 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ on:
workflow_dispatch:
inputs:
version:
description: 'Version'
description: 'Version (example: "1.1.0")'
required: true
default: ''
env:
PUBLISH_WIN_PATH: ./MkvDefaultTrackChanger/MkvDefaultTrackChanger.WinForms/bin/Release/net5.0-windows/win-x64/publish
PUBLISH_LINUX_PATH: ./MkvDefaultTrackChanger/MkvDefaultTrackChanger.Gtk/bin/Release/net5.0/linux-x64/publish
PUBLISH_MAC_PATH: ./MkvDefaultTrackChanger/MkvDefaultTrackChanger.Mac/bin/Release/net5.0/osx-x64/publish
PUBLISH_WIN_PATH: ./MkvDefaultTrackChanger/MkvDefaultTrackChanger.WinForms/bin/Release/net8.0-windows/win-x64/publish
PUBLISH_LINUX_PATH: ./MkvDefaultTrackChanger/MkvDefaultTrackChanger.Gtk/bin/Release/net8.0/linux-x64/publish
PUBLISH_MAC_PATH: ./MkvDefaultTrackChanger/MkvDefaultTrackChanger.Mac/bin/Release/net8.0/osx-x64/publish
jobs:
build:
runs-on: windows-latest
Expand All @@ -20,24 +20,23 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build Windows
run: dotnet publish MkvDefaultTrackChanger/MkvDefaultTrackChanger.WinForms/MkvDefaultTrackChanger.WinForms.csproj --configuration Release -r win-x64 -p:PublishSingleFile=true --self-contained true -p:PublishTrimmed=True -p:IncludeNativeLibrariesForSelfExtract=true -p:Version=${{ github.event.inputs.version }}
run: dotnet publish MkvDefaultTrackChanger/MkvDefaultTrackChanger.WinForms/MkvDefaultTrackChanger.WinForms.csproj -c Release -r win-x64 -p:PublishSingleFile=true -p:Version=${{ github.event.inputs.version }}
- name: Build Linux
run: dotnet publish MkvDefaultTrackChanger/MkvDefaultTrackChanger.Gtk/MkvDefaultTrackChanger.Gtk.csproj --configuration Release -r linux-x64 -p:PublishSingleFile=true --self-contained true -p:PublishTrimmed=True -p:TrimMode=CopyUsed -p:Version=${{ github.event.inputs.version }}
run: dotnet publish MkvDefaultTrackChanger/MkvDefaultTrackChanger.Gtk/MkvDefaultTrackChanger.Gtk.csproj -c Release -r linux-x64 -p:PublishSingleFile=true -p:Version=${{ github.event.inputs.version }}
- name: Build Mac
run: dotnet publish MkvDefaultTrackChanger/MkvDefaultTrackChanger.Mac/MkvDefaultTrackChanger.Mac.csproj --configuration Release -r osx-x64 -p:PublishSingleFile=true --self-contained true -p:Version=${{ github.event.inputs.version }}
run: dotnet publish MkvDefaultTrackChanger/MkvDefaultTrackChanger.Mac/MkvDefaultTrackChanger.Mac.csproj -c Release -r osx-x64 -p:PublishSingleFile=true -p:Version=${{ github.event.inputs.version }}
- name: Zip releases
run: |
powershell Rename-Item $env:PUBLISH_WIN_PATH/MkvDefaultTrackChanger.WinForms.exe MkvDefaultTrackChanger-V${{ github.event.inputs.version }}.exe
powershell Compress-Archive $env:PUBLISH_WIN_PATH/MkvDefaultTrackChanger-V${{ github.event.inputs.version }}.exe ./MkvDefaultTrackChanger-Windows-V${{ github.event.inputs.version }}.zip
powershell Rename-Item $env:PUBLISH_LINUX_PATH/MkvDefaultTrackChanger.Gtk MkvDefaultTrackChanger-V${{ github.event.inputs.version }}.Gtk
powershell Compress-Archive $env:PUBLISH_LINUX_PATH/MkvDefaultTrackChanger-V${{ github.event.inputs.version }}.Gtk ./MkvDefaultTrackChanger-Linux-V${{ github.event.inputs.version }}.zip
# TODO: Fix MacOS archive not working (it extracts to a folder instead of a .app file)
# powershell Rename-Item $env:PUBLISH_MAC_PATH/MkvDefaultTrackChanger.Mac.app ./MkvDefaultTrackChanger-V${{ github.event.inputs.version }}.Mac.app
# powershell Compress-Archive $env:PUBLISH_MAC_PATH/MkvDefaultTrackChanger-V${{ github.event.inputs.version }}.Mac.app ./MkvDefaultTrackChanger-MacOS-V${{ github.event.inputs.version }}.zip
powershell Rename-Item $env:PUBLISH_MAC_PATH/MkvDefaultTrackChanger.Mac.app ./MkvDefaultTrackChanger-V${{ github.event.inputs.version }}.Mac.app
powershell Compress-Archive $env:PUBLISH_MAC_PATH/MkvDefaultTrackChanger-V${{ github.event.inputs.version }}.Mac.app ./MkvDefaultTrackChanger-MacOS-V${{ github.event.inputs.version }}.zip
- name: Create Draft Release
id: create_release
uses: actions/create-release@v1
Expand All @@ -48,7 +47,7 @@ jobs:
release_name: V${{ github.event.inputs.version }}
body: TODO add description and rebuild MacOS locally
draft: true
prerelease: false
prerelease: true
- name: Upload release Windows
uses: actions/[email protected]
env:
Expand All @@ -67,12 +66,12 @@ jobs:
asset_path: ./MkvDefaultTrackChanger-Linux-V${{ github.event.inputs.version }}.zip
asset_name: MkvDefaultTrackChanger-Linux-V${{ github.event.inputs.version }}.zip
asset_content_type: application/zip
#- name: Upload release Mac
# uses: actions/[email protected]
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: ./MkvDefaultTrackChanger-MacOS-V${{ github.event.inputs.version }}.zip
# asset_name: MkvDefaultTrackChanger-MacOS-V${{ github.event.inputs.version }}.zip
# asset_content_type: application/zip
- name: Upload release Mac
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./MkvDefaultTrackChanger-MacOS-V${{ github.event.inputs.version }}.zip
asset_name: MkvDefaultTrackChanger-MacOS-V${{ github.event.inputs.version }}.zip
asset_content_type: application/zip
Binary file removed Assets/Screenshot linux.jpg
Binary file not shown.
Binary file added Assets/Screenshot linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/Screenshot mac.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/Screenshot windows.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
126 changes: 62 additions & 64 deletions MatroskaLib/MatroskaLib.Test/ByteHelperTest.cs
Original file line number Diff line number Diff line change
@@ -1,76 +1,74 @@
using System.Collections.Generic;
using Xunit;

namespace MatroskaLib.Test
namespace MatroskaLib.Test;

public class ByteHelperTest
{
public class ByteHelperTest
public static TheoryData<ulong, List<byte>> TestData1 = new() {
{ 2UL, new () { 0x2 } },
{ 909UL, new () { 0x3, 0x8D } },
{ 1_800_70UL, new () { 0x2, 0xBF, 0x66 } },
};
[Theory, MemberData(nameof(TestData1))]
public void ToBytesTest(ulong value, List<byte> lsBytesExpected)
{
List<byte> lsResult = ByteHelper.ToBytes(value);

Assert.Equal(lsBytesExpected, lsResult);
}

public static TheoryData<List<byte>, List<byte>> TestData2 = new() {
{ new() {0x0, 0x0, 0x0, 0x96}, new () { 0x96 } },
{ new() {0x0, 0x0, 0x5, 0x0, 0x9}, new () { 0x5, 0x0, 0x9 } },
{ new() {0x9}, new () { 0x9 } },
{ new() {}, new () { } }
};
[Theory, MemberData(nameof(TestData2))]
public void RemoveLeftZeroesTest(List<byte> lsBytes, List<byte> lsBytesExpected)
{
ByteHelper.RemoveLeftZeroes(lsBytes);

Assert.Equal(lsBytes, lsBytesExpected);
}

public static IEnumerable<object[]> Data()
{
public static TheoryData<ulong, List<byte>> TestData1 = new () {
{ 2UL, new () { 0x2 } },
{ 909UL, new () { 0x3, 0x8D } },
{ 1_800_70UL, new () { 0x2, 0xBF, 0x66 } },
yield return new object[]
{
new List<byte>{ 0x6B, 0x2D, 0xAE, 0xBB, 0xD7, 0x81, 0x02 },
new List<byte>{ 0x6B, 0x2D, 0xAE, 0xBE, 0xD7, 0x81, 0x02 },
4,
3
};
[Theory, MemberData(nameof(TestData1))]
public void ToBytesTest(ulong value, List<byte> lsBytesExpected)
yield return new object[]
{
List<byte> lsResult = ByteHelper.ToBytes(value);

Assert.Equal(lsBytesExpected, lsResult);
}

public static TheoryData<List<byte>, List<byte>> TestData2 = new () {
{ new() {0x0, 0x0, 0x0, 0x96}, new () { 0x96 } },
{ new() {0x0, 0x0, 0x5, 0x0, 0x9}, new () { 0x5, 0x0, 0x9 } },
{ new() {0x9}, new () { 0x9 } },
{ new() {}, new () { } }
new List<byte>{ 0x81, 0x02, 0xAE, 0x42, 0x83, 0xD7, 0x81, 0x03 },
new List<byte>{ 0x81, 0x02, 0xAE, 0x42, 0x87, 0xD7, 0x81, 0x03 },
5,
4
};
yield return new object[]
{
new List<byte>{ 0x81, 0x02, 0xAE, 0x42, 0x83, 0xD7, 0x81, 0x03 },
new List<byte>{ 0x81, 0x02, 0xAE, 0x42, 0x87, 0xD7, 0x81, 0x03 },
5,
4
};
[Theory, MemberData(nameof(TestData2))]
public void RemoveLeftZeroesTest(List<byte> lsBytes, List<byte> lsBytesExpected)
yield return new object[]
{
ByteHelper.RemoveLeftZeroes(lsBytes);
new List<byte>{ 0x00, 0x00, 0xAE, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0, 0x3A, 0xD7, 81 },
new List<byte>{ 0x00, 0x00, 0xAE, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0, 0x3D, 0xD7, 81 },
11,
3
};
}
[Theory, MemberData(nameof(Data))]

Assert.Equal(lsBytes, lsBytesExpected);
}

public static IEnumerable<object[]> Data() {
yield return new object[]
{
new List<byte>{ 0x6B, 0x2D, 0xAE, 0xBB, 0xD7, 0x81, 0x02 },
new List<byte>{ 0x6B, 0x2D, 0xAE, 0xBE, 0xD7, 0x81, 0x02 },
4,
3
};
yield return new object[]
{
new List<byte>{ 0x81, 0x02, 0xAE, 0x42, 0x83, 0xD7, 0x81, 0x03 },
new List<byte>{ 0x81, 0x02, 0xAE, 0x42, 0x87, 0xD7, 0x81, 0x03 },
5,
4
};
yield return new object[]
{
new List<byte>{ 0x81, 0x02, 0xAE, 0x42, 0x83, 0xD7, 0x81, 0x03 },
new List<byte>{ 0x81, 0x02, 0xAE, 0x42, 0x87, 0xD7, 0x81, 0x03 },
5,
4
};
yield return new object[]
{
new List<byte>{ 0x00, 0x00, 0xAE, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0, 0x3A, 0xD7, 81 },
new List<byte>{ 0x00, 0x00, 0xAE, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0, 0x3D, 0xD7, 81 },
11,
3
};
}
[Theory, MemberData(nameof(Data))]
public void TestChangeLength(List<byte> inputData, List<byte> expectedData, int position, int newAddition)
{
ByteHelper.ChangeLength(inputData, position, 0xAE, newAddition);

public void TestChangeLength(List<byte> inputData, List<byte> expectedData, int position, int newAddition)
{
ByteHelper.ChangeLength(inputData, position, 0xAE, newAddition);

Assert.Equal(inputData, expectedData);
}


Assert.Equal(inputData, expectedData);
}
}
}
Loading

0 comments on commit 84fe4a4

Please sign in to comment.