Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 10, 2025

Tests runtime behavior when creating types with tens of thousands of methods, specifically validating type system limits for async/Task-returning methods around the 2^15 boundary.

Changes

  • Test implementation (src/tests/async/capacity/capacity.cs)

    • Tests instantiation of real classes with specified method counts
    • Three scenarios: 40K int methods (succeeds), 32,750 Task methods (succeeds), 32,763 Task methods (throws TypeLoadException)
  • Large class definitions (source files)

    • LargeClassWithIntMethods.cs - 40,000 methods returning int (~1.4MB)
    • LargeClassWithTaskMethods_Success.cs - 32,750 methods returning Task (~1.7MB)
    • LargeClassWithTaskMethods_Exception.cs - 32,763 methods returning Task (~1.7MB)
  • Build configuration (src/tests/async/capacity/capacity.csproj)

    • Includes all large class source files
    • Overrides parent async directory's build settings to enable for all platforms

Implementation

[Fact]
public static void TestLargeClassWithTaskMethods_Exception()
{
    // Validates type system enforces capacity limits at ~2^15 methods
    Assert.Throws<TypeLoadException>(() =>
    {
        var instance = new LargeClassWithTaskMethods_Exception();
    });
}

The test uses real source-defined classes to validate type loader capacity constraints with actual static types.

Original prompt

This section details on the original issue you should resolve

<issue_title>Add a capacity testcase to test the type system limits with large number of tests</issue_title>
<issue_description>Add a testcase under src/tests/async/capacity with 3 scenarios:

  • allocate an instance of a class with 40000 methods that return int. The allocation should succeed.
  • allocate an instance of a class with 32750 methods that return Task. The allocation should succeed.
  • make a call to a method that allocates an instance of a class with 32763 methods that return Task. The call should throw an exception. </issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@VSadov
Copy link
Member

VSadov commented Dec 10, 2025

@copilot the classes with large number of methods should be real classes defined in source code.

Copilot AI changed the title [WIP] Add capacity testcase for type system limits Add capacity test for type system limits with large method counts Dec 10, 2025
Copilot AI requested a review from VSadov December 10, 2025 22:29
Per @VSadov's feedback, replaced runtime type generation with actual
source-defined classes containing 40k and 32k+ methods.

Co-authored-by: VSadov <[email protected]>
Copy link
Contributor Author

Copilot AI commented Dec 10, 2025

@copilot the classes with large number of methods should be real classes defined in source code.

Changed to real classes defined in source code in commit b748c28. The three large classes are now statically defined with 40,000 and 32,750/32,763 methods respectively.

@VSadov
Copy link
Member

VSadov commented Dec 10, 2025

The new tests are now merged into #122377

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.

Add a capacity testcase to test the type system limits with large number of methods

2 participants