Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
479 commits
Select commit Hold shift + click to select a range
9ff2cfe
Move IIl2CppType to common library
ds5678 Apr 16, 2026
30a2019
Fix field offsets for reference types
ds5678 Apr 16, 2026
ed34d59
Use injected fields in Il2CppToMonoDelegateReference
ds5678 Apr 16, 2026
ee8c599
Support static methods in ClassInjector
ds5678 Apr 17, 2026
9747c43
InjectorHelpers.GetOrCreateImage
ds5678 Apr 17, 2026
9a27eb7
Update comments
ds5678 Apr 17, 2026
801a630
Fix DelegateSupport trampoline code generation
ds5678 Apr 19, 2026
3df7abd
Don't store a managed gc handle in injected classes
ds5678 Apr 19, 2026
a577528
Add il2cpp_raise_exception to IL2CPP.cs
ds5678 Apr 19, 2026
1366927
Don't generate unsafe static method helpers for abstract methods
ds5678 Apr 19, 2026
5b5f55b
Improve creation of IEnum
ds5678 Apr 20, 2026
0508c7e
Update conflict renaming to ensure a consistent result across all games
ds5678 Apr 20, 2026
29d0f78
Rename internal EnumInjector method
ds5678 Apr 20, 2026
d3bce9b
Update IIl2CppType<>:AssemblyName to use Assembly-CSharp as a default
ds5678 Apr 20, 2026
70f1c3a
Add Il2CppMethodInfo* to generated ClassInjector constructor
ds5678 Apr 20, 2026
d84c071
Simplified empty ctor creation
ds5678 Apr 20, 2026
93a40d8
Simplify String -> string conversion code
ds5678 Apr 20, 2026
1fbc1b9
Refactor some code in DelegateSupport
ds5678 Apr 21, 2026
9ef72a4
Make TrampolineHelpers.NativeType more accurate
ds5678 Apr 22, 2026
b4bcb3a
Remove attribute in DelegateSupport specifying a bad calling convention
ds5678 Apr 22, 2026
7a43bdf
Remove unused parameters in DelegateSupport
ds5678 Apr 22, 2026
43c5417
Fix native <-> managed type conversion in DelegateSupport
ds5678 Apr 22, 2026
981c2fc
Remove some bad type validation in DelegateSupport
ds5678 Apr 22, 2026
91850c9
Type injection
ds5678 Apr 22, 2026
d2c5885
Delete RuntimeReflectionHelper
ds5678 Apr 22, 2026
90d2514
Store class pointer for ByReference<> and Pointer<>
ds5678 Apr 22, 2026
fb6d682
Fix ICall generated delegate code
ds5678 Apr 22, 2026
a89ff9f
Conversions from Il2Cpp primitives to system primitives are implicit
ds5678 Apr 22, 2026
25c59b0
Check for null in Class_FromIl2CppType_Hook
ds5678 Apr 22, 2026
ed696d6
Assign tokens for injected classes and structs also
ds5678 Apr 22, 2026
dcbd8b0
Make Il2CppToMonoDelegateReference not nested
ds5678 Apr 22, 2026
abec119
Don't inject nested types
ds5678 Apr 22, 2026
838fb0f
Fix injected interfaces getting a constructor
ds5678 Apr 22, 2026
16b055b
Fix bad parameter wrapping
ds5678 Apr 22, 2026
d626588
Fix by reference types in TrampolineHelpers
ds5678 Apr 22, 2026
95d3fc5
Fix infinite loop in unstripping
ds5678 Apr 22, 2026
9933b35
Ensure structs have a large enough vtable allocated
ds5678 Apr 22, 2026
0cf4087
Il2CppTypePointerStore
ds5678 Apr 22, 2026
3de6379
Cleanup DelegateSupport
ds5678 Apr 22, 2026
f8b4e49
Refactor Class_FromIl2CppType_Hook
ds5678 Apr 22, 2026
94de139
Bump package versions
ds5678 Apr 22, 2026
dab354e
Fix method attributes for object overrides on value types
ds5678 Apr 25, 2026
9e59edd
Include parent classes when creating hash dictionaries in type injection
ds5678 Apr 25, 2026
95a2aab
Fix field injection for value types
ds5678 Apr 25, 2026
37fe2e1
Do not try to init injected classes
ds5678 Apr 25, 2026
f25723d
Actually inject fields
ds5678 Apr 25, 2026
8c8ed3d
Make generated code more robust against null pointers
ds5678 Apr 26, 2026
e58110b
Refactor Il2CppInteropUtils
ds5678 Apr 26, 2026
9af3528
Create a class for assembly injection
ds5678 Apr 26, 2026
b785ef2
Create a generation internals class
ds5678 Apr 26, 2026
c68afe9
Improve unstripping of the throw instruction
ds5678 Apr 26, 2026
f263459
Move methods to GenerationInternals
ds5678 Apr 26, 2026
d72ba86
Move MemoryUtils to injection namespace
ds5678 Apr 26, 2026
1b64683
Delete ThrowHelper
ds5678 Apr 26, 2026
d68564e
Register Il2CppToMonoDelegateReference with object pool
ds5678 Apr 26, 2026
87dceb9
Remove Il2CppType class
ds5678 Apr 26, 2026
09a1e8f
Move exceptions into their namespace
ds5678 Apr 26, 2026
a8e225e
Rename Il2CppTypeHelper to Il2CppType
ds5678 Apr 26, 2026
9307d03
Move RuntimeConfiguration to its own file
ds5678 Apr 26, 2026
5290291
Fix nullable warnings for startup classes
ds5678 Apr 26, 2026
5cdf034
Set .ValueType in TypeInjector
ds5678 Apr 26, 2026
04257ef
Make IndexerAttributeInjectionProcessingLayer more robust
ds5678 Apr 26, 2026
16c46e9
Fix exception hierarchy regression
ds5678 Apr 26, 2026
a92ff62
Fix assembly names not having dll extension
ds5678 Apr 26, 2026
98b5902
Support multiple platforms
ds5678 Apr 27, 2026
184c608
Stripped Code Registration Support
ds5678 Apr 27, 2026
288305f
Fix nullable annotations in Il2CppArrayRank1<> conversions
ds5678 Apr 27, 2026
c793c94
Delete MiniILParser
ds5678 Apr 27, 2026
98428c9
Move AssemblyExtensions to the Runtime project
ds5678 Apr 27, 2026
52bde59
Move InternalsVisibleTo from AssemblyInfo.cs to csproj
ds5678 Apr 28, 2026
669fd88
Convert struct generator from library to CLI
ds5678 Apr 28, 2026
584e31e
Update class initialization
ds5678 Apr 29, 2026
22ee721
Update TrampolineHelpers.NativeType to only use pinvoke for value types
ds5678 Apr 29, 2026
6da9c06
Add source generation attributes
ds5678 Apr 30, 2026
219401d
Use init properties for attributes
ds5678 Apr 30, 2026
c4b5c6d
Remove unnecessary RootNamespace properties
ds5678 Apr 30, 2026
6ab5fb7
Make ByReference<> and Pointer<> readonly
ds5678 Apr 30, 2026
3091782
Add more IIl2CppType<> implementations to the Il2Cppmscorlib stub
ds5678 Apr 30, 2026
0808bff
Fix bug in previous commit
ds5678 Apr 30, 2026
85384b8
Use AssetRipper.Primitives in struct generator
ds5678 Apr 30, 2026
924ee54
Remove ClangSharp from struct generator
ds5678 Apr 30, 2026
e1e2404
Fix IIl2CppType<>.AssemblyName not including the dll extension by def…
ds5678 Apr 30, 2026
ede5898
Use AssetRipper.Primitives for UnityVersion
ds5678 Apr 30, 2026
4cb3d92
Delete extra ParameterInfo methods
ds5678 May 1, 2026
fd43546
Change ParameterInfo version suffixes
ds5678 May 1, 2026
9c983c0
Block scoped namespace for ParameterInfo
ds5678 May 1, 2026
27a5195
Delete static HasNamePosToken
ds5678 May 1, 2026
c411b8b
Refactor ParameterInfo to be more like generated types
ds5678 May 1, 2026
8b60a48
Update struct generator to use headers from https://github.com/nneonn…
ds5678 May 1, 2026
6c22090
Run struct generator
ds5678 May 1, 2026
2b5f45d
Move ElementProtection
ds5678 May 1, 2026
2389ef0
Move EnumUnderlyingType and CodeGenEnumElement into their own files
ds5678 May 1, 2026
5f450a8
Struct generator performance improvements
ds5678 May 1, 2026
0c671e6
Make CodeGenEnumElement a record struct
ds5678 May 1, 2026
1bc4112
Switch struct generator from StringBuilder to IndentedTextWriter
ds5678 May 1, 2026
635230b
Cleanup comments in struct generator
ds5678 May 1, 2026
74e14ba
Cleanup Il2CppStructWrapperGenerator
ds5678 May 1, 2026
706b4ad
Move types to their own files
ds5678 May 1, 2026
e663508
Move Config and ConversionUtils
ds5678 May 1, 2026
d137406
Use collection expressions in struct generator
ds5678 May 1, 2026
1967103
Fix nullable warnings in struct generator
ds5678 May 1, 2026
31a34b1
Delete AddExtraUsing
ds5678 May 1, 2026
d28b306
Remove unused dependency resolution from struct generation
ds5678 May 1, 2026
09415ab
Remove use of Activator.CreateInstance from struct generator
ds5678 May 1, 2026
9afc01d
Formatting
ds5678 May 1, 2026
1ef0f9a
Make CodeGenParameter a record struct
ds5678 May 1, 2026
f401d5e
Move ByRefWrapper to its own file
ds5678 May 1, 2026
dabfd40
Small performance improvement
ds5678 May 1, 2026
3cef1fc
Replace IntPtr and UIntPtr with their keywords
ds5678 May 1, 2026
653e1cb
CodeGenType
ds5678 May 1, 2026
d26f706
Block-scoped namespace for interfaces
ds5678 May 1, 2026
29928df
implement source generator for Il2Cpp type definitions (#9)
Atmudia May 1, 2026
215ef1d
Struct generator generates interfaces too
ds5678 May 2, 2026
6919cef
Source generator tests
ds5678 May 2, 2026
066c3b4
Add InjectedTypePartialAnalyzer to validate decorated types and membe…
Atmudia May 2, 2026
094439a
Analyzer testing framework
ds5678 May 2, 2026
8ab2568
Formatting
ds5678 May 2, 2026
f3e1a62
Use Roslyn LinePositionSpan type
ds5678 May 2, 2026
1984625
Move GeneratePackageOnBuild to individual projects
ds5678 May 3, 2026
623a745
Embed source generator in Il2CppInterop.Runtime package
ds5678 May 3, 2026
e1e559f
Move ResolveICall from IL2CPP to RuntimeInvoke
ds5678 May 3, 2026
6a199ed
Remove xref implementation
ds5678 May 3, 2026
3515500
Move FieldAccess, Il2CppType, and RuntimeInvoke out of the InteropTyp…
ds5678 May 3, 2026
ca0c8d8
Remove NativeStructUtils from public API
ds5678 May 3, 2026
5ca3eee
Move Il2CppToMonoDelegateReference to InteropTypes namespace
ds5678 May 3, 2026
bf20976
Fix namespace not getting changed
ds5678 May 3, 2026
ae9d83e
Minor cleanup to types in the injection namespace
ds5678 May 3, 2026
f7808c0
Change MemoryUtils to SignatureDefinition
ds5678 May 3, 2026
19edd24
XrefScannerLowLevel -> XrefScanner
ds5678 May 3, 2026
eb03c96
Delete Il2CppInterop.Runtime.InteropTypes.CoreLib namespace
ds5678 May 3, 2026
bec2af2
Make Logger a public class and remove InternalsVisibleTo
ds5678 May 3, 2026
c991b60
Move GetIl2CppMethod and GetIl2CppMethodByToken to GenerationInternals
ds5678 May 3, 2026
2d49a23
Use Regex source generation in GenerationInternals
ds5678 May 3, 2026
750f1ae
Fix GetIl2CppValueSize spelling
ds5678 May 3, 2026
1df125f
Improve TrampolineHelpers performance
ds5678 May 3, 2026
228afb1
Fix array initializer syntax and use nameof for MonoField
ds5678 May 3, 2026
7fc93b1
Update class struct generation for VTable
ds5678 May 3, 2026
916fa74
Update il2cpp_class_value_size to use out instead of ref
ds5678 May 3, 2026
5df37f0
Fix bug in previous commit
ds5678 May 3, 2026
05b0a4e
Initial generic class inflation
ds5678 May 3, 2026
e579757
Update NuGet dependencies to latest versions
ds5678 May 3, 2026
6d81a12
Move Il2CppObjectPool to root in Il2CppInterop.Runtime
ds5678 May 3, 2026
35fecf6
Refactor Il2CppObjectPool to not reference Il2CppSystem.Object
ds5678 May 3, 2026
20d65e4
Move IL2CPP to the Common project
ds5678 May 3, 2026
c9c5aa3
Ensure we're using the image name in the generation process
ds5678 May 3, 2026
5f1403e
Update il2cpp_domain_get_assemblies to use out param
ds5678 May 3, 2026
af34d66
Merge Il2CppClassPointerStore into Il2CppType
ds5678 May 4, 2026
b7a6f7c
Fix incorrect unstripping of unbox and unbox.any
ds5678 May 5, 2026
ed0d67c
Fix some naming issues with FieldAccess
ds5678 May 5, 2026
2277957
Validate that class pointer is only being set once
ds5678 May 5, 2026
72f7327
Improved boxing support
ds5678 May 6, 2026
bcd8472
Fix issues unstripping box and unbox.any for Nullable<>
ds5678 May 6, 2026
6009755
Update source generation to account for changes in the IIl2CppType in…
ds5678 May 6, 2026
0e89378
Fix trampolines in TypeInjector for value types
ds5678 May 7, 2026
8277041
Move Il2CppObjectPool and Il2CppType to Common project
ds5678 May 7, 2026
9c09f2f
ObjectPointer.New<>()
ds5678 May 7, 2026
ac6978a
Automatic intializer registration
ds5678 May 7, 2026
33df8b1
Use function pointers instead of delegates in Il2CppObjectPool
ds5678 May 7, 2026
bb70525
Slight name change
ds5678 May 7, 2026
2d0b448
Unstrip TypedReference op codes
ds5678 May 7, 2026
2c99c9c
Fix method translation logging incorrect statistics
ds5678 May 7, 2026
01e20e8
Support using multidimensional arrays in unstripped method bodies
ds5678 May 7, 2026
ad83e3f
Unstrip ldelem_ref and stelem_ref
ds5678 May 7, 2026
3450dc6
Support ldind.ref and stind.ref in unstripping
ds5678 May 7, 2026
baffa93
Avoid unnecessary nop instructions when unstripping method calls
ds5678 May 7, 2026
c5f05a2
Free original method body after translation
ds5678 May 7, 2026
bb7e659
Fix bug in previous commit
ds5678 May 7, 2026
827334c
Improve unstripping of calls to IObject, IValueType, and IEnum methods
ds5678 May 7, 2026
af60c03
Fix signature for interface implementation in Nullable<T>
ds5678 May 7, 2026
ac42f97
Don't register initializers for abstract classes and interfaces
ds5678 May 7, 2026
75865b6
Enable operation without assemblies for unstripping
ds5678 May 8, 2026
439794b
Remove temporary fix for interface base types
ds5678 May 8, 2026
db1dcd0
Remove ExpandMacros backport implementation
ds5678 May 8, 2026
f892f4a
Add multiple diagnostic analyzers for Il2CppInterop injected types (…
Atmudia May 8, 2026
a177ae6
Update AssetRipper.Cpp2IL.Core to version 1.0.3
ds5678 May 8, 2026
ec68969
Formatting
ds5678 May 8, 2026
3897c3e
Add empty processing layer for system interfaces
ds5678 May 9, 2026
0c3df77
Replace comments with Debug.Fail calls
ds5678 May 9, 2026
c453e50
Move GetFullyQualifiedName to TypeInjector
ds5678 May 9, 2026
4474b59
Performance improvements for ContextResolver
ds5678 May 9, 2026
6f33cb8
Rename Il2CppInteropUtils -> Il2CppInternalsAccess
ds5678 May 9, 2026
e22986a
Rename source generator types
ds5678 May 9, 2026
09ae89a
Add static Null property to ByReference<T> and Pointer<T>
ds5678 May 9, 2026
1227d42
Minor comments and changes
ds5678 May 9, 2026
ce83c36
Make INativeStructHandler::Size a property
ds5678 May 9, 2026
741518c
Update Il2CppArrayRank3 indexer to support 3 indices
ds5678 May 9, 2026
306cdfc
Support 4D and 5D arrays
ds5678 May 9, 2026
4853127
Change Il2CppInterop.Runtime.Runtime namespace to Il2CppInterop.Runti…
ds5678 May 9, 2026
c560236
Change namespace for SignatureDefinition
ds5678 May 10, 2026
9c42eae
Move signature hashing logic from TypeInjector to separate files
ds5678 May 10, 2026
618d1fc
Don't create useless maps in TypeInjector
ds5678 May 10, 2026
e5f153d
Use SignatureHash for invokers instead of NamedSignatureHash
ds5678 May 10, 2026
dc7e72b
Update XxHash128Extensions byte Append method
ds5678 May 10, 2026
b9e4bdd
Refactor Il2Cppmscorlib access and remove static field
ds5678 May 10, 2026
d372692
File scoped namespace for hooking classes
ds5678 May 10, 2026
ef6b16b
Refactor detour logic into Hook class
ds5678 May 10, 2026
a4c8225
Remove InjectorHelpers and move its functionality to other classes
ds5678 May 10, 2026
1d12c43
Add Mac extension to Il2CppModule.cs
ds5678 May 10, 2026
0ba3c9a
Rename TrampolineHelper to TrampolineBuilder and make public
ds5678 May 10, 2026
1824bd9
Rename SignatureHash to InvokerSignatureHash
ds5678 May 10, 2026
528b2d9
Move GetOrCreateDelegateType to TrampolineBuilder
ds5678 May 10, 2026
8ecd153
Clean up TrampolineBuilder
ds5678 May 11, 2026
5d4f3ea
Unify trampoline creation
ds5678 May 11, 2026
125c648
Fix issues with DelegateSupport
ds5678 May 11, 2026
f6b2ec6
Change some static abstract methods to static virtual so that they do…
ds5678 May 11, 2026
456a0c8
Make CI happy
ds5678 May 11, 2026
1de9b91
Support primitives in user friendly overload generation
ds5678 May 11, 2026
e4fe509
Refactor: remove GetCurrentAppContext() helper
ds5678 May 15, 2026
661b287
Fix bug in delegate conversion processing layer
ds5678 May 15, 2026
c0a82c8
Ensure delegate types always have addition and subtraction operators
ds5678 May 16, 2026
539efeb
Only use Cpp2IL logger in generator
ds5678 May 16, 2026
8f660cc
Support generating overloads for "virtual" methods
ds5678 May 17, 2026
30ae2f0
Convert Il2Cpp delegates in user friendly overloads
ds5678 May 17, 2026
019dd54
Initial system interface implementation
ds5678 May 17, 2026
3d019a1
Refactor logging and processing layer setup
ds5678 May 17, 2026
8fc2812
Fix NuGet issues related to Il2Cppmscorlib
ds5678 May 17, 2026
7d4cab2
Make system interfaces more complete and fix some bugs
ds5678 May 17, 2026
8966764
Fix nullable warnings for struct handler initialization
ds5678 May 17, 2026
c74a344
Do not use preview language version
ds5678 May 17, 2026
4a53056
Add <auto-generated /> to generated files
ds5678 May 18, 2026
c4c41c2
Suppress CS0649 warning in project file
ds5678 May 18, 2026
22b79d6
Nullable enable by default
ds5678 May 18, 2026
b7a6a9e
Remove Configurations and Platforms from csproj files
ds5678 May 18, 2026
cbf8a77
Add PackageId to csproj files and update packaging config
ds5678 May 18, 2026
1e70143
Use Authors property from Directory.Build.props
ds5678 May 18, 2026
68d66e0
Annotate project for AOT compatibility
ds5678 May 18, 2026
651da70
Formatting
ds5678 May 18, 2026
8fdfa96
Correct documentation for IsInjected property
ds5678 May 18, 2026
12f250a
Explicit conversion operator from the Il2Cpp delegate type to the man…
ds5678 May 18, 2026
b4f7ee4
Update NuGet package versions across projects
ds5678 May 18, 2026
fe87100
Use injected interfaces in SystemInterfaceProcessingLayer
ds5678 May 19, 2026
7921fb8
Include Il2Cppmscorlib.dll in NuGet package build
ds5678 Jun 16, 2026
fa3e987
Update package versions: Cpp2IL.Core and PolySharp
ds5678 Jun 16, 2026
92330d8
Fix source generator output for structs
ds5678 Jun 21, 2026
d9fe016
Fix incorrect warning for fields in injected structs
ds5678 Jun 21, 2026
2349895
Make internal calls more intuitive and efficient
ds5678 Jun 21, 2026
64e7b93
Add FromSystemType for System.Type to Il2CppSystem.Type
ds5678 Jun 22, 2026
5fe2979
Handle missing base interfaces in SystemInterfaceProcessingLayer
ds5678 Jun 22, 2026
9eccd34
Improve InvalidConstraintChecker
ds5678 Jun 22, 2026
67c35b0
Rename obfuscated virtual methods
ds5678 Jun 22, 2026
653ada8
Fix some structs having the abstract flag
ds5678 Jun 22, 2026
5b68530
Handle reference types inheriting from Il2CppSystem.ValueType
ds5678 Jun 22, 2026
dc5fcad
Implement UnboxNative on the Il2Cpp array types
ds5678 Jun 22, 2026
4dd79cf
Fix IL2CPP string return P/Invokes (#13)
RaptorRush135 Jun 23, 2026
4d7c440
Catch exceptions in Il2CppRuntimeClassInit
ds5678 Jun 23, 2026
0abe8ce
Fix null reference in FindClassInit
ds5678 Jun 23, 2026
47d9cb0
Implement system for lazy type initialization
ds5678 Jun 24, 2026
c5a1998
Improve AOT annotations
ds5678 Jun 24, 2026
d14ecd3
Source generate UnityVersionHandler initialization
ds5678 Jun 24, 2026
f7ab842
Fix minor issue with previous commit
ds5678 Jun 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
30 changes: 27 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,29 @@ insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
end_of_line = lf

# Generated code
[*{_AssemblyInfo.cs,.notsupported.cs,AsmOffsets.cs}]
generated_code = true
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_auto_properties = true:suggestion
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
dotnet_style_prefer_conditional_expression_over_return = true:silent
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_compound_assignment = true:suggestion
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 4
end_of_line = lf
dotnet_style_prefer_simplified_interpolation = true:suggestion
dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion

# C# files
[*.cs]
Expand Down Expand Up @@ -54,15 +73,15 @@ dotnet_style_predefined_type_for_member_access = true:suggestion
# name all constant fields using PascalCase
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
dotnet_naming_symbols.constant_fields.applicable_kinds = field
dotnet_naming_symbols.constant_fields.required_modifiers = const
dotnet_naming_style.pascal_case_style.capitalization = pascal_case

# static fields should have s_ prefix
dotnet_naming_rule.static_fields_should_have_prefix.severity = suggestion
dotnet_naming_rule.static_fields_should_have_prefix.symbols = static_fields
dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style
dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style
dotnet_naming_symbols.static_fields.applicable_kinds = field
dotnet_naming_symbols.static_fields.required_modifiers = static
dotnet_naming_symbols.static_fields.applicable_accessibilities = private, internal, private_protected
Expand All @@ -72,7 +91,7 @@ dotnet_naming_style.static_prefix_style.capitalization = camel_case
# internal and private fields should be _camelCase
dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion
dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal
dotnet_naming_style.camel_case_underscore_style.required_prefix = _
Expand Down Expand Up @@ -150,6 +169,11 @@ csharp_space_between_method_declaration_name_and_open_parenthesis = false
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_between_square_brackets = false
csharp_style_namespace_declarations = block_scoped:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_prefer_primary_constructors = true:suggestion
csharp_prefer_system_threading_lock = true:suggestion

# C++ Files
[*.{cpp,h,in}]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
dotnet-version: 10.0.x

- name: Extract Release Version
id: get_version
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/format_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
dotnet-version: 10.0.x

- name: Check format
run: |
Expand Down
5 changes: 2 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@
<PackageOutputPath>../bin/NuGet</PackageOutputPath>
<OutputPath Condition="'$(Configuration)' == 'Release'">../bin/$(MSBuildProjectName)</OutputPath>
<LangVersion>latest</LangVersion>
<Nullable>disable</Nullable>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<RootNamespace>Il2CppInterop</RootNamespace>
<LangVersion>latest</LangVersion>
<PackageIcon>logo_icon.png</PackageIcon>
<PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression>
<PackageReadmeFile>README.md</PackageReadmeFile>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<DebugType>embedded</DebugType>
<ImplicitUsings>enable</ImplicitUsings>
<IsAotCompatible>true</IsAotCompatible>
</PropertyGroup>

<ItemGroup>
Expand Down
10 changes: 10 additions & 0 deletions Documentation/Design/Arrays.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Arrays

## Array Types

Il2Cpp arrays are represented with a closed type hierarchy.

* `Il2CppArrayBase`
* `Il2CppArrayBase<T>`

`Il2CppArrayBase<T>` is the type used everywhere. `Il2CppArrayBase` is just for unstripping certain op codes.
3 changes: 3 additions & 0 deletions Documentation/Design/Attributes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Attributes

Attributes are not applied to types.
187 changes: 187 additions & 0 deletions Documentation/Design/CorLibTypes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
# Core Library Types

## Numeric Primitives, `char`, and `bool`

These are blittable and should be directly reused, kind of. Signatures will use the Il2Cpp types, but implicit conversions will be used inside unstripped method bodies.

```cs
public static Il2CppSystem.Int32 Add(Il2CppSystem.Int32 x, Il2CppSystem.Int32 y)
{
// Conversions to Managed are applied on function entry
ref
int x2 = (int)x;
int y2 = (int)y;

// All operations are done with managed types
int z = x2 + y2;

// If an Il2Cpp primitive must be returned, conversion back is applied right before the return instruction.
return (Il2CppSystem.Int32)z;
}
```

This ensures that CIL opcodes function as expected. However, it can cause some complexities with instance methods on the corlib types. For that, unsafe helpers are used.

```cs
public static Il2CppSystem.String Sum(Il2CppSystem.Int32 x, Il2CppSystem.Int32 y)
{
int z = (int)x + (int)y;
return Unsafe.As<int, Il2CppSystem.Int32>(ref z).ToString();
}
```

## `string`

Strings should not be implicitly marshalled. In other words, `Il2CppSystem.String` should be used.

## `object`

For compatibility with interfaces and value types, this should be emitted as-is, despite the more complicated marshalling involved.

## `Attribute`

## `ValueType` and `Enum`

Boxing to these types is invalid.

## `Exception`

## Counterargument to all of the above

```cs
// Original code
public static void DoSomething<T>(T value) where T : System.IConvertible
{
}
public static void DoSomethingElse()
{
DoSomething<System.Enum>(System.StringComparison.Ordinal);
DoSomething<System.StringComparison>(default);
DoSomething<int>(default);
}

// Unstripped code
public static void DoSomething<T>() where T : Il2CppSystem.IConvertible
{
}
public static void DoSomethingElse()
{
// Which is correct?
// System.Enum fails the constraint check.
// Il2CppSystem.Enum makes the method unusable because boxed enums inherit from `System.Enum` not `Il2CppSystem.Enum`.
DoSomething<System.Enum>(Il2CppSystem.StringComparison.Ordinal);
DoSomething<Il2CppSystem.Enum>(Il2CppSystem.StringComparison.Ordinal);
DoSomething<Il2CppSystem.Enum>(Cast(Il2CppSystem.StringComparison.Ordinal)); // Maybe this is the way it should be emitted?

// If the type is a real enum, it fails the constraint check.
DoSomething<Il2CppSystem.StringComparison>(default);

// Which is correct?
// int fails the constraint check, but is what we currently do.
DoSomething<int>(default);
DoSomething<Il2CppSystem.Int32>(default);
}
private static Il2CppSystem.Enum Cast(object value)
{
if (value is Il2CppSystem.Enum il2cppEnum)
{
return il2cppEnum;
}
if (value is System.Enum sysEnum)
{
throw new NotImplementedException("Cannot cast System.Enum to Il2CppSystem.Enum");
}
throw new InvalidCastException("Cannot cast to Il2CppSystem.Enum");
}

// Proposal
public static void DoSomething<T>() where T : Il2CppSystem.IConvertible
{
}
public static void DoSomethingElse()
{
DoSomething<Il2CppSystem.IEnum>(Il2CppSystem.StringComparison.Ordinal);
DoSomething<Il2CppSystem.StringComparison>(default);
DoSomething<Il2CppSystem.Int32>(default);
}
namespace Il2CppSystem
{
public interface IObject
{
// Instance members of Il2CppSystem.Object
}
public interface IValueType : IObject
{
// No members
}
public interface IEnum : IValueType, Il2CppSystem.IComparable, Il2CppSystem.IFormattable, Il2CppSystem.IConvertible
{
// Instance members of Il2CppSystem.Enum, except for interface implementations
}
public class Object : IObject
{
// A static method should be generated for each instance method
}
public abstract class ValueType : Object, IValueType
{
// A static method should be generated for each instance method
}
public abstract class Enum : ValueType, IEnum
{
// A static method should be generated for each instance method
}
public readonly struct StringComparison : IEnum // Maybe inject other interfaces like System.IEquatable<> for user convenience
{
// [System.Flags] // Only if the Il2Cpp enum has the Flags attribute
private enum __Internal
{
CurrentCulture = 0,
CurrentCultureIgnoreCase = 1,
InvariantCulture = 2,
InvariantCultureIgnoreCase = 3,
Ordinal = 4,
OrdinalIgnoreCase = 5
}

// Might make this `int` instead. The only reason to use `__Internal` is to have a more efficient ToString implementation.
private readonly __Internal value__;

// Sacrifice the ability to use Il2Cpp enums in constants.
public static readonly StringComparison CurrentCulture = new StringComparison(__Internal.CurrentCulture);
public static readonly StringComparison CurrentCultureIgnoreCase = new StringComparison(__Internal.CurrentCultureIgnoreCase);
public static readonly StringComparison InvariantCulture = new StringComparison(__Internal.InvariantCulture);
public static readonly StringComparison InvariantCultureIgnoreCase = new StringComparison(__Internal.InvariantCultureIgnoreCase);
public static readonly StringComparison Ordinal = new StringComparison(__Internal.Ordinal);
public static readonly StringComparison OrdinalIgnoreCase = new StringComparison(__Internal.OrdinalIgnoreCase);

private StringComparison(__Internal value) => value__ = value;
public StringComparison(int value) => value__ = unchecked((__Internal)value);
public static explicit operator int(StringComparison value) => unchecked((int)value.value__);
public static explicit operator StringComparison(int value) => new StringComparison(value);

// Numerical operators like shift

// Override ToString, GetHashCode, Equals, etc.
public override int GetHashCode()
{
// Use the static method from Il2CppSystem.Enum
// We need to ensure that behavior is consistent with the native method.
return Il2CppSystem.Enum.GetHashCode(this);
}

static StringComparison()
{
// OriginalNameAttribute no longer needed.
}
}
public interface ICloneable : IObject, System.ICloneable
{
IObject Clone();

object System.ICloneable.Clone()
{
return Clone();
}
}
}
```
3 changes: 3 additions & 0 deletions Documentation/Design/Delegates.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Delegates

All Il2Cpp delegates have a generated conversion to a system delegate, which might be generated if necessary.
29 changes: 29 additions & 0 deletions Documentation/Design/Enums.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Enums

Enums are converted to readonly structs.

```cs
// Original
public enum ElectricityType
{
Off = 0,
On = 1
}

// Converted
public struct ElectricityType : IObject, IValueType, IEnum, IComparable, IFormattable, IConvertible
{
private readonly Int32 value__;

public static readonly ElectricityType Off = (ElectricityType)0;
public static readonly ElectricityType On = (ElectricityType)1;
}
```

## Generic constraint

`Il2CppSystem.Enum` should be replaced with `Il2CppSystem.IEnum` in generic constraints.

## Interfaces

Additional interfaces like `IEquatable<>`, `IEqualityOperators<,,>`, and `IBitwiseOperators<,,>` could be introduced for user convenience.
7 changes: 7 additions & 0 deletions Documentation/Design/Exceptions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Exceptions

Il2Cpp exceptions each have a cooresponding system exception generated, making up a full hierarchy and enabling try catch support in unstripped code.

## Runtime exceptions

Unstripped code currently allows exceptions (such as `NullReferenceException`) to be thrown by the .NET runtime. Ideally, all such exceptions would be handled.
19 changes: 19 additions & 0 deletions Documentation/Design/Fields.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Fields

## Generated code

```cs
// Reference type
public FieldType fieldName
{
get => throw null;
set => throw null;
}
public static ByReference<FieldType> UnsafeField_fieldName(Class obj) => throw null;
private static readonly IntPtr FieldInfoPtr_fieldIndex;

// Value type
public FieldType fieldName;
public static ByReference<FieldType> UnsafeField_fieldName(ByRerefence<Struct> obj) => throw null;
private static readonly IntPtr FieldInfoPtr_fieldIndex;
```
22 changes: 22 additions & 0 deletions Documentation/Design/GenericMethods.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generic Methods

## Pointers

Pointers are resolved as needed using Il2Cpp reflection. It's fine to do this initialization lazily because all generic type instances are known in advance.

```cs
private static class MethodInfoStoreGeneric_Aggregate<TSource, TAccumulate>
{
internal static System.IntPtr Pointer = IL2CPP.il2cpp_method_get_from_reflection(IL2CPP.Il2CppObjectBaseToPtrNotNull(new MethodInfo(IL2CPP.il2cpp_method_get_object(NativeMethodInfoPtr_Aggregate, Il2CppClassPointerStore<Enumerable>.NativeClassPtr))
.MakeGenericMethod(new Il2CppReferenceArray<Type>(new Type[2]
{
Type.internal_from_handle(IL2CPP.il2cpp_class_get_type(Il2CppClassPointerStore<TSource>.NativeClassPtr)),
Type.internal_from_handle(IL2CPP.il2cpp_class_get_type(Il2CppClassPointerStore<TAccumulate>.NativeClassPtr))
}))));
}
```

If a modder tries to use a generic method instantiation that doesn't exist, an exception is thrown.

* <https://github.com/dreamanlan/il2cpp_ref/blob/09316fe508773b8ced098dae6147b44ee1f6516c/libil2cpp/icalls/mscorlib/System.Reflection/MonoMethod.cpp#L253>
* <https://github.com/dreamanlan/il2cpp_ref/blob/09316fe508773b8ced098dae6147b44ee1f6516c/libil2cpp/icalls/mscorlib/System.Reflection/MonoMethod.cpp#L305>
Loading