Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 28, 2026

Description

Several test files named InvalidCSharp*.il contain types that were invalid C# when introduced but are now expressible in modern C# (11-13). Migrated these types from IL to C# to reduce maintenance burden and demonstrate language evolution. All migrated types are placed in the global namespace alongside their corresponding test classes.

Changes

Ref Fields (C# 11+) - RefFields/InvalidCSharp.ilValidate.cs

  • WithRefField, WithRefStructField, WithTypedReferenceField<T>

Ref Struct Inline Arrays (C# 12+) - InlineArray/InvalidCSharpInlineArray.ilInlineArrayValid.cs

  • SpanArr - inline array of 100 Span<object> elements

Generic allows ref struct Constraint (C# 13) - ByRefLike/InvalidCSharp.ilValidate.cs

  • GenericValueType_Over<T>, GenericByRefLike_Over<T> with where T : allows ref struct
  • Helper ref structs: ByRefLikeType, ByRefLikeType2, ByRefLikeType<T>, ByRefLikeTypeWithInterface
  • Test interfaces and implementations: SimpleInterface, DefaultInterface, RS_DI1, RS_DI2
  • RegularValueType

Example

Before (IL):

.class public sequential ansi sealed beforefieldinit InvalidCSharp.WithRefField
    extends [System.Runtime]System.ValueType
{
    .custom instance void [System.Runtime]System.Runtime.CompilerServices.IsByRefLikeAttribute::.ctor()
    .field public string& Str
}

After (C#):

public ref struct WithRefField
{
    public ref string Str;
}

Notes

  • All migrated types are in the global namespace, matching the test classes in their respective files
  • The using InvalidCSharp; directive remains in test files for types still in IL (intentionally invalid types used for negative testing)
  • Intentionally invalid types (e.g., classes/interfaces with byreflike constraint) remain in IL for negative testing
  • Net reduction: 291 lines (581 IL removed, 290 C# added)
  • No test behavior changes - migrated types maintain identical semantics

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits January 28, 2026 23:31
… to C#

Co-authored-by: jkoritzinsky <1571408+jkoritzinsky@users.noreply.github.com>
Co-authored-by: jkoritzinsky <1571408+jkoritzinsky@users.noreply.github.com>
Co-authored-by: jkoritzinsky <1571408+jkoritzinsky@users.noreply.github.com>
Co-authored-by: jkoritzinsky <1571408+jkoritzinsky@users.noreply.github.com>
Copilot AI changed the title [WIP] Migrate valid C# types from InvalidCSharp*.il files Migrate valid C# types from InvalidCSharp*.il test files Jan 28, 2026
Copilot AI requested a review from jkoritzinsky January 28, 2026 23:42
Copy link
Member

@jkoritzinsky jkoritzinsky left a comment

Choose a reason for hiding this comment

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

@copilot the types that have been moved to C# can be moved out of the InvalidCSharp namespace and into the same namespace as the tests in their corresponding files.

Co-authored-by: jkoritzinsky <1571408+jkoritzinsky@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 29, 2026

@copilot the types that have been moved to C# can be moved out of the InvalidCSharp namespace and into the same namespace as the tests in their corresponding files.

Done. Moved all migrated types to the global namespace in commit ab1d3f1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants