Skip to content

Adopt C# 12 syntax across library and tests for .NET 8#30

Merged
shibayan merged 2 commits intomasterfrom
copilot/update-csharp-features-dotnet-8
Apr 19, 2026
Merged

Adopt C# 12 syntax across library and tests for .NET 8#30
shibayan merged 2 commits intomasterfrom
copilot/update-csharp-features-dotnet-8

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 19, 2026

This updates the codebase to use the latest C# language features available with .NET 8. The change standardizes language configuration and applies targeted C# 12 syntax upgrades without altering runtime behavior.

  • Language version alignment

    • Set library project language version explicitly to 12.0 (the latest C# level for .NET 8) instead of floating latest.
  • Core library modernization

    • Replaced legacy empty array initialization with C# 12 collection expressions.
    • Replaced verbose constructor typing with target-typed new(...) where the type is already known.
    • Simplified temporary array construction in dynamic meta-object binding logic using typed collection expressions.
  • Test data modernization

    • Converted test record arrays to collection expressions.
    • Switched dictionary test fixtures to indexer initializers for clearer key/value construction.

Example of the applied style update:

private static readonly string[] s_emptyArray = [];
Expression[] parameters = [Expression.Constant(binder.Name), value.Expression];

public static readonly IReadOnlyList<object> CsvAnonymousRecords =
[
    new { Id = 1, Name = "kazuakix", Location = "Wakayama" },
    new { Id = 2, Name = "daruyanagi", Location = "Ehime" },
    new { Id = 3, Name = "buchizo", Location = "Osaka" }
];

Copilot AI and others added 2 commits April 18, 2026 09:34
@shibayan shibayan requested a review from Copilot April 19, 2026 01:22
@shibayan shibayan marked this pull request as ready for review April 19, 2026 01:23
@shibayan shibayan merged commit edce45c into master Apr 19, 2026
3 checks passed
@shibayan shibayan deleted the copilot/update-csharp-features-dotnet-8 branch April 19, 2026 01:23
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the solution to consistently use C# 12 features on .NET 8, modernizing several initialization patterns in the core library and test fixtures.

Changes:

  • Pin the library project’s C# language version to 12.0.
  • Modernize core library code using C# 12 collection expressions and target-typed new.
  • Update test data fixtures to use collection expressions and dictionary indexer initializers.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
CsvHelper.FastDynamic/CsvRecordMetaObject.cs Replace legacy array initializations with C# 12 collection expressions in DLR binding.
CsvHelper.FastDynamic/CsvReaderExtensions.cs Use collection expression for empty list initialization in async record collection.
CsvHelper.FastDynamic/CsvHelper.FastDynamic.csproj Pin C# language version to 12.0.
CsvHelper.FastDynamic/CsvHeader.cs Use target-typed new for dictionary construction.
CsvHelper.FastDynamic.Tests/TestData.cs Modernize test fixtures with collection expressions and indexer initializers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread CsvHelper.FastDynamic/CsvHelper.FastDynamic.csproj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants