### Run Demo Project Source: https://github.com/andreyakinshin/kdlsharp/blob/main/AGENTS.md Executes the KdlSharp.Demo project to showcase library features and usage examples. This is a good starting point for understanding how to use the library. ```bash # Run demo project (shows usage examples) dotnet run --project KdlSharp.Demo/KdlSharp.Demo.csproj ``` -------------------------------- ### Run KdlSharp Demo Application Source: https://github.com/andreyakinshin/kdlsharp/blob/main/KdlSharp.Demo/README.md Navigate to the KdlSharp.Demo directory and run the dotnet application to execute all demo examples. ```bash cd KdlSharp.Demo dotnet run ``` -------------------------------- ### Basic Parsing KDL from String Source: https://github.com/andreyakinshin/kdlsharp/blob/main/KdlSharp.Demo/README.md Demonstrates fundamental parsing operations for getting started with KdlSharp, including parsing KDL from strings and accessing nodes, arguments, and properties. ```csharp // Basic parsing operations for getting started with KdlSharp. // - Parsing KDL documents from strings // - Accessing nodes, arguments, and properties // - Working with nested child nodes // - Using `TryParse` for safe parsing ``` -------------------------------- ### Install KdlSharp Package Source: https://github.com/andreyakinshin/kdlsharp/blob/main/README.md Use the dotnet CLI to add the KdlSharp package to your project. ```bash dotnet add package KdlSharp ``` -------------------------------- ### Run Specific Examples Interactively Source: https://github.com/andreyakinshin/kdlsharp/blob/main/KdlSharp.Demo/README.md Modify Program.cs to call only the desired example methods for interactive exploration. ```csharp Run only specific examples BasicParsing.Run(); Serialization.Run(); ``` -------------------------------- ### Initialize Git Submodule Source: https://github.com/andreyakinshin/kdlsharp/blob/main/AGENTS.md Initializes and recursively updates Git submodules, including the KDL specification repository. This is typically run once during initial setup. ```bash # Initialize submodule (first time setup) git submodule update --init --recursive ``` -------------------------------- ### Check Code Style Compliance Source: https://github.com/andreyakinshin/kdlsharp/blob/main/AGENTS.md Verify that the code style adheres to the project's standards without making any changes. This is part of the quick start checklist for code quality. ```bash dotnet format KdlSharp.sln --verify-no-changes ``` -------------------------------- ### Generate Coverage Report Source: https://github.com/andreyakinshin/kdlsharp/blob/main/AGENTS.md Generates an HTML code coverage report from collected data. Requires the `dotnet-reportgenerator-globaltool` to be installed. ```bash # Install: dotnet tool install -g dotnet-reportgenerator-globaltool dotnet test --collect:"XPlat Code Coverage" reportgenerator -reports:"**/coverage.cobertura.xml" -targetdir:"coverage-report" -reporttypes:Html ``` -------------------------------- ### KDL Query Language Usage Source: https://github.com/andreyakinshin/kdlsharp/blob/main/KdlSharp.Demo/README.md Showcases the CSS-selector-like query language for finding nodes in KDL documents, including examples of name matching, property filters, and child/descendant selectors. ```csharp // CSS-selector-like query language for finding nodes. // - Name matching, property filters, child (`>`) and descendant (`>>`) selectors // - Compiled queries for reuse ``` -------------------------------- ### Run Demo Project (Release) Source: https://github.com/andreyakinshin/kdlsharp/blob/main/AGENTS.md Executes the KdlSharp.Demo project in Release mode for potentially better performance. Useful for observing library behavior under optimized conditions. ```bash # Run in Release mode for better performance dotnet run --project KdlSharp.Demo/KdlSharp.Demo.csproj --configuration Release ``` -------------------------------- ### Build Solution (Release) Source: https://github.com/andreyakinshin/kdlsharp/blob/main/AGENTS.md Builds the entire KdlSharp solution in Release mode. This is recommended for performance-sensitive builds and final packaging. ```bash # Build in Release mode dotnet build KdlSharp.sln --configuration Release ``` -------------------------------- ### Build KdlSharp Solution Source: https://github.com/andreyakinshin/kdlsharp/blob/main/AGENTS.md Build the KdlSharp solution in Release configuration. This is a standard step for ensuring the project compiles correctly. ```bash dotnet build KdlSharp.sln --configuration Release ``` -------------------------------- ### Run All Benchmarks (Release) Source: https://github.com/andreyakinshin/kdlsharp/blob/main/AGENTS.md Executes all performance benchmarks in Release mode. This command can take several minutes to complete and is used for performance analysis. ```bash # Run all performance benchmarks (takes several minutes) dotnet run --project KdlSharp.Benchmarks/KdlSharp.Benchmarks.csproj --configuration Release ``` -------------------------------- ### Build Solution (Debug) Source: https://github.com/andreyakinshin/kdlsharp/blob/main/AGENTS.md Builds the entire KdlSharp solution in Debug mode. Use this for general development and debugging. ```bash # Build entire solution (Debug) dotnet build KdlSharp.sln ``` -------------------------------- ### Create NuGet Package Source: https://github.com/andreyakinshin/kdlsharp/blob/main/AGENTS.md Creates a NuGet package for the KdlSharp library. This command is used for packaging the library for distribution. ```bash # Create NuGet package dotnet pack KdlSharp/KdlSharp.csproj --configuration Release # Output location: KdlSharp/bin/Release/KdlSharp.*.nupkg ``` -------------------------------- ### Initialize Git Submodules Source: https://github.com/andreyakinshin/kdlsharp/blob/main/KdlSharp.Tests/OfficialTests/README.md Ensures the official KDL specification test suite submodule is initialized. ```bash git submodule update --init --recursive ``` -------------------------------- ### Build Main Library (Release) Source: https://github.com/andreyakinshin/kdlsharp/blob/main/AGENTS.md Builds only the main KdlSharp library project in Release mode. Useful for focusing on library development without building other projects. ```bash # Build only the main library dotnet build KdlSharp/KdlSharp.csproj --configuration Release ``` -------------------------------- ### Advanced KDL Document Construction Source: https://github.com/andreyakinshin/kdlsharp/blob/main/KdlSharp.Demo/README.md Demonstrates advanced usage of KdlSharp, including programmatic document construction using a fluent API, extension methods for property access, and version-aware parsing with custom formatting. ```csharp // Document construction, extension methods, and formatting customization. // - Fluent API for building nodes // - Extension methods for property access // - Version-aware parsing, custom formatting ``` -------------------------------- ### Run KdlSharp Tests Source: https://github.com/andreyakinshin/kdlsharp/blob/main/AGENTS.md Execute all tests for the KdlSharp project in Release configuration. This verifies the correctness of the implementation against expected behavior. ```bash dotnet test KdlSharp.Tests/KdlSharp.Tests.csproj --configuration Release ``` -------------------------------- ### Configure KDL Serializer Options Source: https://github.com/andreyakinshin/kdlsharp/blob/main/README.md Demonstrates various options available for configuring the KdlSerializer, such as naming policies and target KDL version. ```csharp var options = new KdlSerializerOptions { // Custom root node name (default: "root") RootNodeName = "config", // Naming policy: CamelCase, PascalCase, SnakeCase, KebabCase, None (default: KebabCase) PropertyNamingPolicy = KdlNamingPolicy.KebabCase, // Include null values in output (default: false) IncludeNullValues = true, // Add type annotations like (i32), (string), (bool) (default: false) WriteTypeAnnotations = true, // Write simple values as arguments vs properties (default: true) UseArgumentsForSimpleValues = true, // Flatten single-child objects into parent node (default: false) FlattenSingleChildObjects = false, // Target KDL version: V1 uses bare true/false/null, V2 uses #true/#false/#null (default: V2) TargetVersion = KdlVersion.V2 }; ``` -------------------------------- ### KDL Document Navigation with Extension Methods Source: https://github.com/andreyakinshin/kdlsharp/blob/main/KdlSharp.Demo/README.md Highlights the use of LINQ-like extension methods for KDL document navigation, including typed property access, tree traversal (descendants, ancestors), and convenient node searching. ```csharp // LINQ-like document navigation. // - Typed property access // - Tree traversal (descendants, ancestors) // - Convenient node searching ``` -------------------------------- ### POCO Serialization and Deserialization Source: https://github.com/andreyakinshin/kdlsharp/blob/main/KdlSharp.Demo/README.md Shows how to serialize .NET objects to KDL format and deserialize KDL back to strongly-typed objects, including the use of naming policies like kebab-case. ```csharp // POCO serialization and deserialization for mapping .NET objects to KDL. // - Serializing records to KDL // - Deserializing back to objects // - Using naming policies (kebab-case) // - Idiomatic KDL output with proper formatting ``` -------------------------------- ### Run Tests (Release Mode) Source: https://github.com/andreyakinshin/kdlsharp/blob/main/AGENTS.md Executes all unit tests in Release mode. This can help identify performance-related test issues. ```bash # Run tests in Release mode dotnet test KdlSharp.Tests/KdlSharp.Tests.csproj --configuration Release ``` -------------------------------- ### Build Documents Programmatically Source: https://github.com/andreyakinshin/kdlsharp/blob/main/README.md Constructs a KDL document object in memory and converts it to a KDL string. ```csharp var doc = new KdlDocument(); doc.Nodes.Add( new KdlNode("package") .AddArgument("my-app") .AddProperty("version", "1.0.0") .AddChild(new KdlNode("author").AddArgument("Alice")) ); string kdl = doc.ToKdlString(); ``` -------------------------------- ### Run All Tests Source: https://github.com/andreyakinshin/kdlsharp/blob/main/AGENTS.md Executes all unit tests in the KdlSharp.Tests project. This is a primary step for verifying code changes. ```bash # Run all tests dotnet test KdlSharp.Tests/KdlSharp.Tests.csproj ``` -------------------------------- ### Run Tests with Detailed Output Source: https://github.com/andreyakinshin/kdlsharp/blob/main/AGENTS.md Executes all unit tests and displays detailed output. Useful for diagnosing failing tests. ```bash # Run tests with detailed output dotnet test KdlSharp.Tests/KdlSharp.Tests.csproj --verbosity normal ``` -------------------------------- ### Run Official Tests with Verbose Output Source: https://github.com/andreyakinshin/kdlsharp/blob/main/KdlSharp.Tests/OfficialTests/README.md Executes the official KDL specification tests with detailed output. ```bash dotnet test --filter "FullyQualifiedName~OfficialTestRunner" --verbosity normal ``` -------------------------------- ### Asynchronous KDL Operations Source: https://github.com/andreyakinshin/kdlsharp/blob/main/KdlSharp.Demo/README.md Demonstrates asynchronous file reading and writing, stream-based operations, and cancellation token support for non-blocking I/O patterns in KdlSharp. ```csharp // Asynchronous file reading and writing. // - Stream-based async operations // - Cancellation token support // - Non-blocking I/O patterns ``` -------------------------------- ### Programmatically Create Raw Strings Source: https://github.com/andreyakinshin/kdlsharp/blob/main/README.md Construct KdlString objects programmatically, specifying the desired string type. Use static helpers for raw strings, automatically computing hash counts or explicitly setting them, and supporting multi-line content. ```csharp // Create a simple raw string (hash count computed automatically) var raw = KdlString.Raw(@"C:\\path\\to\\file"); // Create a raw string with explicit hash count var rawWithHashes = KdlString.Raw("contains \"# pattern", hashCount: 2); // Create a multi-line raw string var rawMultiLine = KdlString.Raw("line1\nline2", multiLine: true); ``` -------------------------------- ### Restore NuGet Packages Source: https://github.com/andreyakinshin/kdlsharp/blob/main/AGENTS.md Restores all NuGet packages required by the solution. Use this command when setting up the project or after pulling changes. ```bash # Restore NuGet packages for solution dotnet restore KdlSharp.sln ``` -------------------------------- ### Verify Formatting Changes with Dotnet Format Source: https://github.com/andreyakinshin/kdlsharp/blob/main/AGENTS.md Check what formatting changes would be applied without actually modifying files. Use the --verbosity diagnostic for detailed output. ```bash dotnet format KdlSharp.sln --verify-no-changes --verbosity diagnostic ``` -------------------------------- ### Include KDL Version Marker Source: https://github.com/andreyakinshin/kdlsharp/blob/main/README.md Configure the KdlFormatter to include a version marker at the beginning of the serialized output. This is useful for specifying the KDL version compatibility. ```csharp using KdlSharp.Formatting; using KdlSharp.Settings; var settings = new KdlFormatterSettings { IncludeVersionMarker = true, // Emit /- kdl-version N at start TargetVersion = KdlVersion.V2 }; var formatter = new KdlFormatter(settings); var kdl = formatter.Serialize(doc); ``` -------------------------------- ### Run Official Tests Source: https://github.com/andreyakinshin/kdlsharp/blob/main/KdlSharp.Tests/OfficialTests/README.md Executes the official KDL specification tests using the KdlSharp test runner. ```bash dotnet test --filter "FullyQualifiedName~OfficialTestRunner" ``` -------------------------------- ### Synchronous File I/O in KdlSharp Source: https://github.com/andreyakinshin/kdlsharp/blob/main/KdlSharp.Demo/README.md Covers synchronous file read/write operations in KdlSharp, including error handling for file I/O and custom formatter settings with different indentation styles. ```csharp // Synchronous file read/write. // - Error handling for file I/O // - Custom formatter settings // - Different indentation styles ``` -------------------------------- ### Parse KDL from File Source: https://github.com/andreyakinshin/kdlsharp/blob/main/AGENTS.md Parses a KDL document directly from a file path. Ensures the file exists and is readable. ```csharp var doc = KdlDocument.ParseFile("config.kdl"); ``` -------------------------------- ### Check Formatting for Specific Project Source: https://github.com/andreyakinshin/kdlsharp/blob/main/AGENTS.md Verifies code style compliance for a specific project without modifying its files. Useful for targeted checks. ```bash # Check formatting for specific project dotnet format KdlSharp/KdlSharp.csproj --verify-no-changes ``` -------------------------------- ### Check Code Style Compliance Source: https://github.com/andreyakinshin/kdlsharp/blob/main/AGENTS.md Verifies code style compliance across the solution without modifying files. Use this to ensure adherence to project formatting standards. ```bash # Check code style compliance (does NOT modify files) dotnet format KdlSharp.sln --verify-no-changes ``` -------------------------------- ### Error Handling in KDL Parsing Source: https://github.com/andreyakinshin/kdlsharp/blob/main/KdlSharp.Demo/README.md Illustrates error handling patterns for KDL parsing, including catching KdlParseException with line and column information, and using the TryParse pattern for safe parsing. ```csharp // Error handling patterns and parsing failure scenarios. // - Handling parse exceptions with detailed error messages // - Line and column information for syntax errors // - Source context for debugging // - Safe parsing with `TryParse` ``` -------------------------------- ### Fix Formatting Issues with Dotnet Format Source: https://github.com/andreyakinshin/kdlsharp/blob/main/AGENTS.md Automatically fix all formatting issues in the KdlSharp solution. This command applies formatting changes directly. ```bash dotnet format KdlSharp.sln ``` -------------------------------- ### Clear NuGet Cache and Restore Source: https://github.com/andreyakinshin/kdlsharp/blob/main/AGENTS.md Clears the local NuGet package cache and restores dependencies for the solution. Use this to resolve package restore issues. ```bash dotnet nuget locals all --clear dotnet restore KdlSharp.sln ``` -------------------------------- ### Parse KDL from String Source: https://github.com/andreyakinshin/kdlsharp/blob/main/AGENTS.md Parses a KDL document from a given string. Use this for in-memory KDL data. ```csharp var doc = KdlDocument.Parse(kdlText); ``` -------------------------------- ### Async Parse and Write KDL to Streams Source: https://github.com/andreyakinshin/kdlsharp/blob/main/README.md Utilize asynchronous methods for parsing KDL documents from streams and writing them to streams. These methods support cancellation tokens and stream lifetime control. ```csharp var doc = await KdlDocument.ParseStreamAsync(fileStream, cancellationToken: token); await doc.WriteToAsync(outputStream, leaveOpen: true); ``` -------------------------------- ### Run Tests with Code Coverage Collection Source: https://github.com/andreyakinshin/kdlsharp/blob/main/AGENTS.md Executes tests and collects code coverage data. Requires the 'XPlat Code Coverage' collector. ```bash # Run tests with code coverage dotnet test KdlSharp.Tests/KdlSharp.Tests.csproj --collect:"XPlat Code Coverage" ``` -------------------------------- ### KDL Schema Definition and Validation Source: https://github.com/andreyakinshin/kdlsharp/blob/main/KdlSharp.Demo/README.md Explains how to define KDL schemas programmatically and validate documents against them, including handling validation errors and applying rules like required properties and patterns. ```csharp // Schema definition and validation for enforcing document structure. // - Permissive schemas, required properties, validation rules (length, pattern) // - Error reporting ``` -------------------------------- ### Update to Latest Official Tests Source: https://github.com/andreyakinshin/kdlsharp/blob/main/KdlSharp.Tests/OfficialTests/README.md Updates the local submodule to the latest version of the official KDL tests. ```bash git submodule update --remote --merge ``` -------------------------------- ### Parse Legacy v1 KDL Documents Source: https://github.com/andreyakinshin/kdlsharp/blob/main/README.md Parses a KDL document using settings to target the legacy v1 specification. ```csharp var settings = new KdlParserSettings { TargetVersion = KdlVersion.V1 }; var doc = KdlDocument.Parse("node true false null", settings); ``` -------------------------------- ### Parse a KDL Document Source: https://github.com/andreyakinshin/kdlsharp/blob/main/README.md Parses a KDL string into a KdlDocument object and demonstrates accessing nodes and properties. ```csharp using KdlSharp; var doc = KdlDocument.Parse(@" server host=\"localhost\" port=8080 { database connection=\"postgres://localhost/mydb\" } "); var server = doc.Nodes[0]; Console.WriteLine(server.GetProperty("host")?.AsString()); // "localhost" Console.WriteLine(server.GetProperty("port")?.AsInt32()); // 8080 ``` -------------------------------- ### Clean Build Artifacts Source: https://github.com/andreyakinshin/kdlsharp/blob/main/AGENTS.md Removes build artifacts from the solution. Use this to ensure a clean build environment. ```bash # Clean build artifacts dotnet clean KdlSharp.sln ``` -------------------------------- ### Clear NuGet Cache and Restore Source: https://github.com/andreyakinshin/kdlsharp/blob/main/AGENTS.md Clears the local NuGet package cache and then restores packages for the solution. This is useful for resolving dependency issues. ```bash # Clean NuGet cache (if having dependency issues) dotnet nuget locals all --clear dotnet restore KdlSharp.sln ``` -------------------------------- ### Run Specific Benchmark Categories Source: https://github.com/andreyakinshin/kdlsharp/blob/main/AGENTS.md Executes specific categories of performance benchmarks using the `--filter` option. This allows for targeted performance testing. ```bash # Run specific benchmark categories dotnet run --project KdlSharp.Benchmarks/KdlSharp.Benchmarks.csproj --configuration Release -- --filter "*ParsingBenchmark*" dotnet run --project KdlSharp.Benchmarks/KdlSharp.Benchmarks.csproj --configuration Release -- --filter "QueryBenchmarks.*" dotnet run --project KdlSharp.Benchmarks/KdlSharp.Benchmarks.csproj --configuration Release -- --filter "SchemaBenchmarks.*" ``` -------------------------------- ### Auto-fix Formatting Issues Source: https://github.com/andreyakinshin/kdlsharp/blob/main/AGENTS.md Automatically applies code formatting rules to the solution. This command modifies files to match the project's style guidelines. ```bash # Auto-fix formatting issues dotnet format KdlSharp.sln ``` -------------------------------- ### Token-by-Token KDL Parsing Source: https://github.com/andreyakinshin/kdlsharp/blob/main/README.md Process KDL data at a token level using `KdlReader` for scenarios requiring fine-grained control over parsing. This allows iterating through tokens and inspecting their types and locations. ```csharp using KdlSharp.Parsing; using var reader = new StringReader(kdlText); using var kdlReader = new KdlReader(reader); while (kdlReader.Read()) { Console.WriteLine($"[{kdlReader.Line}:{kdlReader.Column}] {kdlReader.TokenType}"); } ``` -------------------------------- ### Try Parse KDL Safely Source: https://github.com/andreyakinshin/kdlsharp/blob/main/AGENTS.md Attempts to parse KDL text without throwing exceptions. Returns a boolean indicating success and an error object if parsing fails. ```csharp if (KdlDocument.TryParse(kdlText, out var doc, out var error)) { // Success } else { // error contains detailed parse exception } ``` -------------------------------- ### Test Manifest JSON Format Source: https://github.com/andreyakinshin/kdlsharp/blob/main/KdlSharp.Tests/OfficialTests/README.md Specifies version requirements for KDL tests. Test names must not include the .kdl extension, and property names use snake_case. ```json { "defaultVersion": "v2", "tests": { "v2_only": ["test1", "test2"], "v1_only": ["test3"], "both": ["test4", "test5"] } } ``` -------------------------------- ### Async Streaming KDL Serialization Source: https://github.com/andreyakinshin/kdlsharp/blob/main/README.md Serialize large sequences of KDL objects efficiently to a stream using `SerializeStreamAsync`. This method supports asynchronous data sources, cancellation tokens, and serializer options. ```csharp // Serialize an async sequence directly to a stream await serializer.SerializeStreamAsync(GetEventsAsync(), outputStream); async IAsyncEnumerable GetEventsAsync() { // Objects are serialized one at a time as they are yielded await foreach (var evt in eventSource.ReadAsync()) yield return evt; } ``` -------------------------------- ### Serialize Objects to KDL Source: https://github.com/andreyakinshin/kdlsharp/blob/main/README.md Serializes a C# record object to a KDL string using KdlSerializer with custom options. ```csharp using KdlSharp.Serialization; public record ServerConfig(string Host, int Port, bool UseSsl); var config = new ServerConfig("localhost", 8080, true); var serializer = new KdlSerializer(new KdlSerializerOptions { RootNodeName = "server", PropertyNamingPolicy = KdlNamingPolicy.KebabCase }); string kdl = serializer.Serialize(config); // server host="localhost" port=8080 use-ssl=#true ``` -------------------------------- ### Run Specific Test Class Source: https://github.com/andreyakinshin/kdlsharp/blob/main/AGENTS.md Executes tests belonging to a specific class. Use the `--filter` option to target tests by their fully qualified name. ```bash # Run specific test class dotnet test KdlSharp.Tests/KdlSharp.Tests.csproj --filter "FullyQualifiedName~BasicParsingTests" ``` -------------------------------- ### Serialize POCO to KDL Source: https://github.com/andreyakinshin/kdlsharp/blob/main/AGENTS.md Serializes a Plain Old C# Object (POCO) into a KDL string. Allows customization of root node name and property naming conventions. ```csharp using KdlSharp.Serialization; // POCO to KDL var serializer = new KdlSerializer(new KdlSerializerOptions { RootNodeName = "config", PropertyNamingPolicy = KdlNamingPolicy.KebabCase }); string kdl = serializer.Serialize(myObject); ``` -------------------------------- ### Validate KDL Against Schema Source: https://github.com/andreyakinshin/kdlsharp/blob/main/README.md Validates a KDL document against a defined schema and reports any validation errors. ```csharp using KdlSharp.Schema; using KdlSharp.Schema.Rules; var schema = new SchemaDocument( new SchemaInfo { Title = "Config Schema" }, nodes: new[] { new SchemaNode("server", properties: new[] { new SchemaProperty("port", required: true, validationRules: new[] { new GreaterThanRule(0), new LessThanRule(65536) }) }) } ); var result = KdlSchema.Validate(doc, schema); if (!result.IsValid) foreach (var error in result.Errors) Console.WriteLine($"{error.Path}: {error.Message}"); ``` -------------------------------- ### Deserialize KDL to Objects Source: https://github.com/andreyakinshin/kdlsharp/blob/main/README.md Deserializes a KDL string into a C# object using the KdlSerializer. ```csharp var kdl = @"server host=\"localhost\" port=8080 use-ssl=#true"; var config = serializer.Deserialize(kdl); ``` -------------------------------- ### Deserialize KDL to POCO Source: https://github.com/andreyakinshin/kdlsharp/blob/main/AGENTS.md Deserializes a KDL string into a specified C# object type (POCO). Requires the KdlSerializer to be configured. ```csharp using KdlSharp.Serialization; // KDL to POCO var obj = serializer.Deserialize(kdl); ``` -------------------------------- ### Query Nodes in a KDL Document Source: https://github.com/andreyakinshin/kdlsharp/blob/main/README.md Uses KdlQuery to find specific nodes within a parsed KDL document. ```csharp using KdlSharp.Query; var doc = KdlDocument.Parse(@" package { dependencies { lodash "^4.0" } dev-dependencies { jest "^29.0" } } "); // Find all dependency nodes var deps = KdlQuery.Execute(doc, "package >> dependencies"); ``` -------------------------------- ### Parse KDL Document from Stream Source: https://github.com/andreyakinshin/kdlsharp/blob/main/README.md Read KDL documents directly from a stream using `KdlDocument.ParseStream`. Control whether the stream is closed after parsing using the `leaveOpen` parameter. ```csharp using var fileStream = File.OpenRead("config.kdl"); // Parse from stream, closing it after parsing (default) var doc = KdlDocument.ParseStream(fileStream); // Or keep the stream open for further operations var doc = KdlDocument.ParseStream(fileStream, leaveOpen: true); ``` -------------------------------- ### Check Git Submodule Status Source: https://github.com/andreyakinshin/kdlsharp/blob/main/AGENTS.md Displays the status of all Git submodules, indicating their current commit and whether they are up-to-date. ```bash # Check submodule status git submodule status ``` -------------------------------- ### Update Git Submodule Source: https://github.com/andreyakinshin/kdlsharp/blob/main/AGENTS.md Updates Git submodules to their latest versions. Use `--remote` to fetch from the remote and `--merge` to merge the changes. ```bash # Update submodule to latest git submodule update --remote --merge ``` -------------------------------- ### Preserve Original String Formatting Source: https://github.com/andreyakinshin/kdlsharp/blob/main/README.md Enable string type preservation to maintain the original formatting (identifier, quoted, raw, or multi-line) of strings when serializing a KDL document. This ensures round-tripping of complex string literals. ```csharp using KdlSharp.Formatting; using KdlSharp.Settings; // Parse a document with various string types var doc = KdlDocument.Parse("node identifier-value #\"raw string\"# \"quoted\""); // Enable PreserveStringTypes to maintain original formatting var settings = new KdlFormatterSettings { PreserveStringTypes = true }; var formatter = new KdlFormatter(settings); var kdl = formatter.Serialize(doc); ``` -------------------------------- ### Preserve Raw String Delimiter Source: https://github.com/andreyakinshin/kdlsharp/blob/main/README.md When using `PreserveStringTypes`, raw strings with custom hash delimiters are correctly serialized, maintaining their original hash count. This is crucial for round-tripping raw strings that contain `#` characters. ```csharp // Parse a raw string with multiple hashes var doc = KdlDocument.Parse("node ##\"contains \"# pattern\"##"); // The hash count is preserved when serializing with PreserveStringTypes var settings = new KdlFormatterSettings { PreserveStringTypes = true }; var formatter = new KdlFormatter(settings); var kdl = formatter.Serialize(doc); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.