### Install Simfile.NET via NuGet Package Manager Source: https://github.com/finc06/simfile.net/blob/main/README.md Instructions for installing the Simfile.NET NuGet package using the .NET CLI. ```bash dotnet add package Simfile.NET ``` -------------------------------- ### Install Simfile.NET via Package Manager Console Source: https://github.com/finc06/simfile.net/blob/main/README.md Instructions for installing the Simfile.NET NuGet package using the Package Manager Console in Visual Studio. ```powershell Install-Package Simfile.NET ``` -------------------------------- ### Build and Test Project (Bash) Source: https://github.com/finc06/simfile.net/blob/main/RELEASE.md Commands to restore dependencies, build the project in Release configuration, and run unit tests. Essential for ensuring code quality before packaging. ```bash cd Simfile.NET dotnet restore dotnet build --configuration Release dotnet test --configuration Release --verbosity normal ``` -------------------------------- ### Simfile.NET Unit Test Examples Source: https://github.com/finc06/simfile.net/blob/main/CONTRIBUTING.md Illustrates how to write unit tests for Simfile.NET using xUnit. It includes examples for testing successful parsing of valid simfile data and for verifying that an exception is thrown when parsing invalid data. ```csharp [Fact] public void ParseSimfile_WithValidData_ShouldReturnCorrectTitle() { // Arrange var simfileContent = "#TITLE:Test Song;"; // Act var simfile = SimfileLibrary.LoadString(simfileContent); // Assert simfile.Title.Should().Be("Test Song"); } [Fact] public void ParseSimfile_WithInvalidData_ShouldThrowException() { // Arrange var invalidContent = "invalid simfile data"; // Act & Assert Action act = () => SimfileLibrary.LoadString(invalidContent); act.Should().Throw(); } ``` -------------------------------- ### Build Release Configuration (Bash) Source: https://github.com/finc06/simfile.net/blob/main/RELEASE.md Bash command to build the project specifically for the Release configuration. This is part of the pre-release checklist and ensures optimizations are applied. ```bash dotnet build --configuration Release ``` -------------------------------- ### Create NuGet Package (Bash) Source: https://github.com/finc06/simfile.net/blob/main/RELEASE.md Command to create a NuGet package (`.nupkg` file) from the compiled project in Release configuration. The output is directed to a 'nupkg' directory. ```bash dotnet pack --configuration Release --output ./nupkg ``` -------------------------------- ### Publish NuGet Package (Bash) Source: https://github.com/finc06/simfile.net/blob/main/RELEASE.md Command to push the generated NuGet package to the official NuGet.org repository. Requires the NuGet API key and specifies the source URL. ```bash dotnet nuget push ./nupkg/Simfile.NET.1.0.1.nupkg \ --api-key YOUR_NUGET_API_KEY \ --source https://api.nuget.org/v3/index.json ``` -------------------------------- ### Add Simfile.NET via PackageReference Source: https://github.com/finc06/simfile.net/blob/main/README.md Example of how to add the Simfile.NET NuGet package to a .NET project file using PackageReference. ```xml ``` -------------------------------- ### Add Simfile.NET Package (Bash) Source: https://github.com/finc06/simfile.net/blob/main/RELEASE.md Bash commands to create a new console application, navigate into its directory, and add the Simfile.NET package with a specific version. Used for post-release verification. ```bash dotnet new console -n TestApp cd TestApp dotnet add package Simfile.NET --version 1.0.1 dotnet build ``` -------------------------------- ### Run Tests Locally (Bash) Source: https://github.com/finc06/simfile.net/blob/main/RELEASE.md Bash command to execute all tests in the project with normal verbosity. This is a fundamental step in the pre-release checklist to ensure code quality. ```bash dotnet test --verbosity normal ``` -------------------------------- ### Prepare Release Branch (Bash) Source: https://github.com/finc06/simfile.net/blob/main/RELEASE.md Commands to ensure the main branch is up-to-date and to create a new release branch for version management. This helps isolate release-specific changes. ```bash git checkout main git pull origin main # Create release branch (optional for hotfixes) git checkout -b release/v1.0.1 ``` -------------------------------- ### C# Coding Standards Example Source: https://github.com/finc06/simfile.net/blob/main/CONTRIBUTING.md Demonstrates good and bad practices in C# for Simfile.NET, focusing on naming conventions, constructor null checks, and XML documentation for public APIs. ```csharp // ✅ Good public class SimfileParser { private readonly string _filePath; public SimfileParser(string filePath) { _filePath = filePath ?? throw new ArgumentNullException(nameof(filePath)); } /// /// Parses the simfile and returns the result. /// /// The parsed simfile. public Simfile Parse() { // Implementation } } // ❌ Avoid public class simfileparser { public string filepath; public simfileparser(string path) { filepath = path; // No null check } public Simfile parse() // No documentation { // Implementation } } ``` -------------------------------- ### Update Version Information (XML and Markdown) Source: https://github.com/finc06/simfile.net/blob/main/RELEASE.md Demonstrates how to update the project's version number in the .csproj file and document changes in the CHANGELOG.md file. Follows Semantic Versioning guidelines. ```xml 1.0.1 ``` ```markdown ## [1.0.1] - 2025-01-10 ### Added - New feature descriptions ### Fixed - Bug fix descriptions ### Changed - Change descriptions ``` -------------------------------- ### Commit and Tag Release (Bash) Source: https://github.com/finc06/simfile.net/blob/main/RELEASE.md Commands to stage and commit version changes, create a Git tag for the new release version, and push the tag to the remote repository. This is crucial for version control and automated releases. ```bash # Commit version changes git add . git commit -m "Bump version to v1.0.1" # Create and push tag git tag v1.0.1 git push origin v1.0.1 ``` -------------------------------- ### Create Hotfix Release (Git Bash) Source: https://github.com/finc06/simfile.net/blob/main/RELEASE.md Steps to create a hotfix branch, commit fixes, tag a new version, and push it to the remote repository using Git. This follows the deletion of a problematic release. Assumes the user is in the project directory. ```git-bash git checkout v1.0.1 git checkout -b hotfix/v1.0.2 # Make fixes git commit -m "Fix critical issue" git tag v1.0.2 git push origin v1.0.2 ``` -------------------------------- ### Rollback NuGet Package (Bash) Source: https://github.com/finc06/simfile.net/blob/main/RELEASE.md Command to delete a specific version of a NuGet package from NuGet.org. This is the first step in a rollback procedure if a release has critical issues. Requires the package name, version, API key, and NuGet source URL. ```bash dotnet nuget delete Simfile.NET 1.0.1 \ --api-key YOUR_API_KEY \ --source https://api.nuget.org/v3/index.json ``` -------------------------------- ### Restore, Build, and Test Simfile.NET Project Source: https://github.com/finc06/simfile.net/blob/main/CONTRIBUTING.md Commands to restore dependencies, build the project, and run tests for Simfile.NET. These are essential steps after cloning the repository to ensure the development environment is set up correctly. ```bash dotnet restore dotnet build ``` ```bash cd Simfile.NET.Tests dotnet test --verbosity normal ``` -------------------------------- ### Directory and Pack Operations in C# Source: https://github.com/finc06/simfile.net/blob/main/README.md Shows how to open a simfile from a directory (preferring .ssc over .sm) and how to iterate through all simfiles within a pack directory. ```csharp // Open simfile from directory (prefers .ssc over .sm) var (simfile, filename) = SimfileLibrary.OpenDirectory("/path/to/song/"); // Open all simfiles in a pack directory foreach (var (packSimfile, packFilename) in SimfileLibrary.OpenPack("/path/to/pack/")) { Console.WriteLine($"Found: {packSimfile.Title} ({packFilename})"); } ``` -------------------------------- ### Clone Simfile.NET Repository Source: https://github.com/finc06/simfile.net/blob/main/CONTRIBUTING.md Clones the Simfile.NET repository locally using Git and navigates into the project directory. This is the first step in setting up the development environment. ```bash git clone https://github.com/yourusername/Simfile.NET.git cd Simfile.NET ``` -------------------------------- ### XML Documentation for Simfile Loading API (C#) Source: https://github.com/finc06/simfile.net/blob/main/CONTRIBUTING.md Provides XML documentation for the `Open` method, detailing its purpose, parameters, return value, and potential exceptions. This adheres to standard C# XML documentation practices for public APIs. ```csharp /// /// Loads a simfile from the specified file path. /// /// The path to the simfile. /// Whether to use strict parsing mode. /// The loaded simfile. /// Thrown when the file doesn't exist. /// Thrown when parsing fails. public static Simfile Open(string filePath, bool strict = true) ``` -------------------------------- ### Create a New Simfile in C# Source: https://github.com/finc06/simfile.net/blob/main/README.md Shows how to create a new SSC simfile, set its metadata and create a chart, then serialize and save it to a file. ```csharp // Create a new SSC simfile var simfile = SimfileLibrary.CreateBlank(useSSC: true); var ssc = ((SscSimfileWrapper)simfile).SscSimfile; // Set basic metadata ssc.Title = "My New Song"; ssc.Artist = "My Artist"; ssc.Music = "song.ogg"; ssc.Offset = "0.000"; ssc.Bpms = "0.000=128.000"; // Create a chart var chart = SscChart.CreateBlank(); chart.StepsType = "dance-single"; chart.Difficulty = "Medium"; chart.Meter = "5"; chart.Notes = "1000\n0100\n0010\n0001"; ssc.SscCharts.Add(chart); // Save to file File.WriteAllText("newsong.ssc", ssc.Serialize()); ``` -------------------------------- ### Run .NET Tests Source: https://github.com/finc06/simfile.net/blob/main/README.md This command executes the comprehensive test suite for the Simfile.NET library using the 'dotnet test' command. It verifies parsing, encoding detection, text handling, timing data, chart analysis, and serialization roundtrip. ```bash cd Simfile.NET.Tests dotnet test --verbosity normal ``` -------------------------------- ### Read a Simfile in C# Source: https://github.com/finc06/simfile.net/blob/main/README.md Demonstrates how to load a simfile from a file using SimfileLibrary.Open, with automatic encoding detection, and access its basic properties and charts. ```csharp using Simfile.NET; // Load a simfile from file with automatic encoding detection var simfile = SimfileLibrary.Open("song.sm"); // Access basic properties Console.WriteLine($"Title: {simfile.Title}"); Console.WriteLine($"Artist: {simfile.Artist}"); Console.WriteLine($"BPM: {simfile.BaseSimfile.DisplayBpm}"); // Access charts foreach (var chart in simfile.Charts) { Console.WriteLine($"Difficulty: {chart.Difficulty} ({chart.Meter})"); Console.WriteLine($"Steps Type: {chart.StepsType}"); } ``` -------------------------------- ### Restore .NET Dependencies Source: https://github.com/finc06/simfile.net/blob/main/README.md This command restores all necessary dependencies for the Simfile.NET project. It should be run after cloning the repository and before building or testing the project. ```bash dotnet restore ``` -------------------------------- ### Structured Logging for Debugging (C#) Source: https://github.com/finc06/simfile.net/blob/main/CONTRIBUTING.md Demonstrates the use of structured logging with `ActivitySource` for debugging purposes. This pattern helps in tracing execution flow and capturing error details during parsing operations. ```csharp // Use structured logging for debugging using var activity = ActivitySource.StartActivity("ParseSimfile"); activity?.SetTag("simfile.path", filePath); try { // Parsing logic } catch (Exception ex) { activity?.SetStatus(ActivityStatusCode.Error, ex.Message); throw; } ``` -------------------------------- ### Safe Simfile Mutations in C# Source: https://github.com/finc06/simfile.net/blob/main/README.md Illustrates how to safely modify a simfile using the `Mutate` method, which automatically creates a backup and ensures changes are only committed upon successful disposal. ```csharp // Safely modify a simfile with automatic backup using (var mutator = SimfileLibrary.Mutate("song.sm", backupFilename: "song.sm.bak")) { mutator.Simfile.BaseSimfile.Title = "Updated Title"; // File is automatically saved when disposed // If an exception occurs, no changes are written } ``` -------------------------------- ### Work with Simfile Chart Data in C# Source: https://github.com/finc06/simfile.net/blob/main/README.md Illustrates how to access and process the note data within simfile charts, including splitting note lines and accessing properties like meter and radar values. ```csharp var simfile = SimfileLibrary.Open("song.sm"); var smWrapper = (SmSimfileWrapper)simfile; foreach (var chart in smWrapper.SmSimfile.SmCharts) { // Access chart properties Console.WriteLine($"Chart: {chart.StepsType} {chart.Difficulty}"); Console.WriteLine($"Meter: {chart.Meter}"); Console.WriteLine($"Radar Values: {chart.RadarValues}"); // Process note data var noteLines = chart.Notes?.Split('\n') ?? Array.Empty(); Console.WriteLine($"Note lines: {noteLines.Length}"); } ``` -------------------------------- ### Simfile Encoding Detection in C# Source: https://github.com/finc06/simfile.net/blob/main/README.md Demonstrates two methods for handling simfile encoding: opening with a specific encoding and opening with automatic encoding detection. ```csharp // Open with specific encoding var simfile = SimfileLibrary.Open("japanese_song.sm", encoding: Encoding.UTF8); // Open with automatic encoding detection var (simfileAuto, detectedEncoding) = SimfileLibrary.OpenWithDetectedEncoding("song.sm"); Console.WriteLine($"Detected encoding: {detectedEncoding.EncodingName}"); ``` -------------------------------- ### Create Feature Branch for Contributions Source: https://github.com/finc06/simfile.net/blob/main/CONTRIBUTING.md Steps to create a new feature branch for contributions. It involves checking out the 'develop' branch, pulling the latest changes, and then creating a new branch prefixed with 'feature/'. ```bash git checkout develop git pull origin develop git checkout -b feature/my-new-feature ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.