Skip to content

Wrap default values in a struct#578

Open
ds5678 wants to merge 3 commits into
SamboyCoding:developmentfrom
AssetRipper:default-value-wrapped-by-struct
Open

Wrap default values in a struct#578
ds5678 wants to merge 3 commits into
SamboyCoding:developmentfrom
AssetRipper:default-value-wrapped-by-struct

Conversation

@ds5678

@ds5678 ds5678 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

This ensures that we properly distinguish the constant null from having no default value at all.

@coveralls

coveralls commented Jul 8, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 29700142382

Coverage increased (+0.04%) to 37.803%

Details

  • Coverage increased (+0.04%) from the base build.
  • Patch coverage: 10 uncovered changes across 6 files (55 of 65 lines covered, 84.62%).
  • 2 coverage regressions across 2 files.

Uncovered Changes

File Changed Covered %
Cpp2IL.Core/Model/Contexts/ConcreteGenericFieldAnalysisContext.cs 2 0 0.0%
Cpp2IL.Core/Model/Contexts/ConcreteGenericParameterAnalysisContext.cs 2 0 0.0%
Cpp2IL.Core/Model/Contexts/ParameterAnalysisContext.cs 16 14 87.5%
LibCpp2IL/Reflection/Il2CppParameterReflectionData.cs 2 0 0.0%
Cpp2IL.Core/Model/Contexts/InjectedParameterAnalysisContext.cs 3 2 66.67%
Cpp2IL.Core/ProcessingLayers/StableRenamingProcessingLayer.cs 1 0 0.0%
Total (17 files) 65 55 84.62%

Coverage Regressions

2 previously-covered lines in 2 files lost coverage.

File Lines Losing Coverage Coverage
Cpp2IL.Core/Model/Contexts/ConcreteGenericParameterAnalysisContext.cs 1 30.77%
Cpp2IL.Core/Model/Contexts/InjectedParameterAnalysisContext.cs 1 69.23%

Coverage Stats

Coverage Status
Relevant Lines: 13144
Covered Lines: 5326
Line Coverage: 40.52%
Relevant Branches: 8656
Covered Branches: 2915
Branch Coverage: 33.68%
Branches in Coverage %: Yes
Coverage Strength: 175459.83 hits per line

💛 - Coveralls

@SamboyCoding

Copy link
Copy Markdown
Owner

Not sure I actually like this concept. The correct thing to do here is to check the attributes to see if there is a literal or default value.

@ds5678
ds5678 force-pushed the default-value-wrapped-by-struct branch from 8e28f8d to 34c5ee8 Compare July 16, 2026 22:26
@ds5678

ds5678 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

Not sure I actually like this concept. The correct thing to do here is to check the attributes to see if there is a literal or default value.

Everywhere that the constant value is used, we also check the attributes.

@SamboyCoding

SamboyCoding commented Jul 19, 2026

Copy link
Copy Markdown
Owner

Everywhere that the constant value is used, we also check the attributes.

this is my point. If we check the attributes, we KNOW whether it's a real null or no default value. This PR seems to be trying to solve something which is just user error.

@ds5678

ds5678 commented Jul 19, 2026

Copy link
Copy Markdown
Contributor Author

Everywhere that the constant value is used, we also check the attributes.

this is my point. If we check the attributes, we KNOW whether it's a real null or no default value.

No, we don't; LibCpp2IL returns null for errors, too.

if (pointer <= 0) return null;

default:
return null;

This PR seems to be trying to solve something which is just user error.

The motivation for this PR was to enable Il2CppInterop to override parameter default values from 0/false to literal null (default(Struct)).

ds5678 added 3 commits July 19, 2026 12:11
This ensures that we properly distinguish the constant null from having no default value at all.
@ds5678
ds5678 force-pushed the default-value-wrapped-by-struct branch from 34c5ee8 to 27652f6 Compare July 19, 2026 19:11
@SamboyCoding

Copy link
Copy Markdown
Owner

The motivation for this PR was to enable Il2CppInterop to override parameter default values from 0/false to literal null (default(Struct)).

This should be done by changing attributes. The error handling is exception case and should probably be changed to actually throw an exception.

@ds5678

ds5678 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

The motivation for this PR was to enable Il2CppInterop to override parameter default values from 0/false to literal null (default(Struct)).

This should be done by changing attributes.

I can't. Setting the object? override value to null does nothing because the default value is not null. The object? override is ambiguous between "no override" and "override to null".

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