Skip to content

Ensure the base type and interfaces of generic instance types are instantiated#549

Open
ds5678 wants to merge 1 commit into
SamboyCoding:developmentfrom
AssetRipper:generic-instance-type-base-type
Open

Ensure the base type and interfaces of generic instance types are instantiated#549
ds5678 wants to merge 1 commit into
SamboyCoding:developmentfrom
AssetRipper:generic-instance-type-base-type

Conversation

@ds5678

@ds5678 ds5678 commented May 11, 2026

Copy link
Copy Markdown
Contributor

This aligns with behavior for DeclaringType.

This pull request depends on #575.

@ds5678 ds5678 marked this pull request as draft May 11, 2026 23:38
@ds5678 ds5678 force-pushed the generic-instance-type-base-type branch 2 times, most recently from f0f137a to 5f32b62 Compare July 5, 2026 01:40
@ds5678 ds5678 marked this pull request as ready for review July 5, 2026 01:42
@coveralls

coveralls commented Jul 5, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 28810477125

Coverage increased (+0.1%) to 36.238%

Details

  • Coverage increased (+0.1%) from the base build.
  • Patch coverage: 4 uncovered changes across 2 files (47 of 51 lines covered, 92.16%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
Cpp2IL.Core/Model/Contexts/GenericInstanceTypeAnalysisContext.cs 34 31 91.18%
Cpp2IL.Core/Model/Contexts/GenericArgumentList.cs 9 8 88.89%
Total (7 files) 51 47 92.16%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 12947
Covered Lines: 5078
Line Coverage: 39.22%
Relevant Branches: 8492
Covered Branches: 2691
Branch Coverage: 31.69%
Branches in Coverage %: Yes
Coverage Strength: 171675.64 hits per line

💛 - Coveralls

@ds5678 ds5678 changed the title Ensure the base type of generic instance types is instantiated Ensure the base type and interfaces of generic instance types are instantiated Jul 5, 2026
@SamboyCoding

Copy link
Copy Markdown
Owner

Branch has conflicts that I don't have permission to resolve.

@ds5678 ds5678 force-pushed the generic-instance-type-base-type branch from 5f32b62 to db19c06 Compare July 6, 2026 17:28
if (_underConstruction2 != null && _underConstruction2.TryGetValue((genericType.AppContext, genericType, genericArgumentsList), out var partial))
return partial;

return genericType.AppContext.GenericInstanceTypesByConstruction

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This means we have 2 separate caches now, GenericInstanceTypesByIl2CppType, and this one. Which means you can have 2 instances of the exact same GIT, both considered canonical, in 2 different dictionaries, and break reference equality, which we do rely on in some places. Needs to be unified somehow.


namespace Cpp2IL.Core.Model.Contexts;

internal readonly record struct GenericArgumentList(List<TypeAnalysisContext> Arguments)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This list is a) exposed publicly, b) used for hash code calculation, and c) the same reference is exposed as GenericArguments on the GIT. GenericArgumentList is used as part of the key in the GenericInstanceTypesByConstruction dict. Creates kind of a footgun because someone could change a GIT's arguments, which would change the key of an item in the dictionary which can break shit. E.g. if you have a Dictionary<string, string>, change it to Dictionary<string, object>, then call GetOrCreate to try to get a Dictionary<string, object>, the key won't be found in the dict because its hashcode has changed, and you'll get a second (or potentially third, when combined with the other issue) instance for the same GIT.

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