Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
486 commits
Select commit Hold shift + click to select a range
d83c342
Don't store a managed gc handle in injected classes
ds5678 Apr 19, 2026
3f7ef53
Add il2cpp_raise_exception to IL2CPP.cs
ds5678 Apr 19, 2026
62237d5
Don't generate unsafe static method helpers for abstract methods
ds5678 Apr 19, 2026
5c39a6e
Improve creation of IEnum
ds5678 Apr 20, 2026
db65a8e
Update conflict renaming to ensure a consistent result across all games
ds5678 Apr 20, 2026
ef92010
Rename internal EnumInjector method
ds5678 Apr 20, 2026
e753df3
Update IIl2CppType<>:AssemblyName to use Assembly-CSharp as a default
ds5678 Apr 20, 2026
df89db5
Add Il2CppMethodInfo* to generated ClassInjector constructor
ds5678 Apr 20, 2026
8accb6d
Simplified empty ctor creation
ds5678 Apr 20, 2026
54ca1d7
Simplify String -> string conversion code
ds5678 Apr 20, 2026
33e0444
Refactor some code in DelegateSupport
ds5678 Apr 21, 2026
056cfb9
Make TrampolineHelpers.NativeType more accurate
ds5678 Apr 22, 2026
57e480a
Remove attribute in DelegateSupport specifying a bad calling convention
ds5678 Apr 22, 2026
a022408
Remove unused parameters in DelegateSupport
ds5678 Apr 22, 2026
3911155
Fix native <-> managed type conversion in DelegateSupport
ds5678 Apr 22, 2026
36fabfb
Remove some bad type validation in DelegateSupport
ds5678 Apr 22, 2026
8744d89
Type injection
ds5678 Apr 22, 2026
1ee54e9
Delete RuntimeReflectionHelper
ds5678 Apr 22, 2026
52817fe
Store class pointer for ByReference<> and Pointer<>
ds5678 Apr 22, 2026
fd6aca3
Fix ICall generated delegate code
ds5678 Apr 22, 2026
b3137c7
Conversions from Il2Cpp primitives to system primitives are implicit
ds5678 Apr 22, 2026
77ca76a
Check for null in Class_FromIl2CppType_Hook
ds5678 Apr 22, 2026
93e5469
Assign tokens for injected classes and structs also
ds5678 Apr 22, 2026
49f5e0c
Make Il2CppToMonoDelegateReference not nested
ds5678 Apr 22, 2026
e63b879
Don't inject nested types
ds5678 Apr 22, 2026
606de34
Fix injected interfaces getting a constructor
ds5678 Apr 22, 2026
f410dc3
Fix bad parameter wrapping
ds5678 Apr 22, 2026
8f3367d
Fix by reference types in TrampolineHelpers
ds5678 Apr 22, 2026
7a4bc30
Fix infinite loop in unstripping
ds5678 Apr 22, 2026
5436076
Ensure structs have a large enough vtable allocated
ds5678 Apr 22, 2026
9ead9dc
Il2CppTypePointerStore
ds5678 Apr 22, 2026
f3ddb7e
Cleanup DelegateSupport
ds5678 Apr 22, 2026
6e9e74c
Refactor Class_FromIl2CppType_Hook
ds5678 Apr 22, 2026
74e960b
Bump package versions
ds5678 Apr 22, 2026
a714dfc
Fix method attributes for object overrides on value types
ds5678 Apr 25, 2026
19c79c5
Include parent classes when creating hash dictionaries in type injection
ds5678 Apr 25, 2026
50be03d
Fix field injection for value types
ds5678 Apr 25, 2026
1ef5836
Do not try to init injected classes
ds5678 Apr 25, 2026
b59b5b9
Actually inject fields
ds5678 Apr 25, 2026
01c84af
Make generated code more robust against null pointers
ds5678 Apr 26, 2026
5bc7717
Refactor Il2CppInteropUtils
ds5678 Apr 26, 2026
c162bde
Create a class for assembly injection
ds5678 Apr 26, 2026
0f2d707
Create a generation internals class
ds5678 Apr 26, 2026
8794f54
Improve unstripping of the throw instruction
ds5678 Apr 26, 2026
f0fc4fb
Move methods to GenerationInternals
ds5678 Apr 26, 2026
315de29
Move MemoryUtils to injection namespace
ds5678 Apr 26, 2026
625ea84
Delete ThrowHelper
ds5678 Apr 26, 2026
a16b1dc
Register Il2CppToMonoDelegateReference with object pool
ds5678 Apr 26, 2026
509e295
Remove Il2CppType class
ds5678 Apr 26, 2026
98f1519
Move exceptions into their namespace
ds5678 Apr 26, 2026
f3aa4d8
Rename Il2CppTypeHelper to Il2CppType
ds5678 Apr 26, 2026
5e160d2
Move RuntimeConfiguration to its own file
ds5678 Apr 26, 2026
5359913
Fix nullable warnings for startup classes
ds5678 Apr 26, 2026
c7bd8dc
Set .ValueType in TypeInjector
ds5678 Apr 26, 2026
c932c18
Make IndexerAttributeInjectionProcessingLayer more robust
ds5678 Apr 26, 2026
e6b7f81
Fix exception hierarchy regression
ds5678 Apr 26, 2026
ea1093b
Fix assembly names not having dll extension
ds5678 Apr 26, 2026
3363a72
Support multiple platforms
ds5678 Apr 27, 2026
e005479
Stripped Code Registration Support
ds5678 Apr 27, 2026
1c4b51b
Fix nullable annotations in Il2CppArrayRank1<> conversions
ds5678 Apr 27, 2026
af73093
Delete MiniILParser
ds5678 Apr 27, 2026
d5c69a0
Move AssemblyExtensions to the Runtime project
ds5678 Apr 27, 2026
8c933d1
Move InternalsVisibleTo from AssemblyInfo.cs to csproj
ds5678 Apr 28, 2026
0061a50
Convert struct generator from library to CLI
ds5678 Apr 28, 2026
7883b7f
Update class initialization
ds5678 Apr 29, 2026
41b7a99
Update TrampolineHelpers.NativeType to only use pinvoke for value types
ds5678 Apr 29, 2026
7078e75
Add source generation attributes
ds5678 Apr 30, 2026
7564d40
Use init properties for attributes
ds5678 Apr 30, 2026
f66ca1e
Remove unnecessary RootNamespace properties
ds5678 Apr 30, 2026
7480a6d
Make ByReference<> and Pointer<> readonly
ds5678 Apr 30, 2026
a814c2e
Add more IIl2CppType<> implementations to the Il2Cppmscorlib stub
ds5678 Apr 30, 2026
c7c9145
Fix bug in previous commit
ds5678 Apr 30, 2026
1d87680
Use AssetRipper.Primitives in struct generator
ds5678 Apr 30, 2026
cc1914d
Remove ClangSharp from struct generator
ds5678 Apr 30, 2026
bf81dfb
Fix IIl2CppType<>.AssemblyName not including the dll extension by def…
ds5678 Apr 30, 2026
0613396
Use AssetRipper.Primitives for UnityVersion
ds5678 Apr 30, 2026
5e32f2b
Delete extra ParameterInfo methods
ds5678 May 1, 2026
6c6166b
Change ParameterInfo version suffixes
ds5678 May 1, 2026
948230f
Block scoped namespace for ParameterInfo
ds5678 May 1, 2026
9ac26b7
Delete static HasNamePosToken
ds5678 May 1, 2026
07fef5c
Refactor ParameterInfo to be more like generated types
ds5678 May 1, 2026
173c5d0
Update struct generator to use headers from https://github.com/nneonn…
ds5678 May 1, 2026
a670b4d
Run struct generator
ds5678 May 1, 2026
6355552
Move ElementProtection
ds5678 May 1, 2026
525a315
Move EnumUnderlyingType and CodeGenEnumElement into their own files
ds5678 May 1, 2026
e4d65d0
Struct generator performance improvements
ds5678 May 1, 2026
cc41e09
Make CodeGenEnumElement a record struct
ds5678 May 1, 2026
7cca187
Switch struct generator from StringBuilder to IndentedTextWriter
ds5678 May 1, 2026
1706609
Cleanup comments in struct generator
ds5678 May 1, 2026
10c3687
Cleanup Il2CppStructWrapperGenerator
ds5678 May 1, 2026
e9ffa23
Move types to their own files
ds5678 May 1, 2026
0242c5e
Move Config and ConversionUtils
ds5678 May 1, 2026
94dac15
Use collection expressions in struct generator
ds5678 May 1, 2026
bc24b28
Fix nullable warnings in struct generator
ds5678 May 1, 2026
3a9b637
Delete AddExtraUsing
ds5678 May 1, 2026
ead61fd
Remove unused dependency resolution from struct generation
ds5678 May 1, 2026
645c07f
Remove use of Activator.CreateInstance from struct generator
ds5678 May 1, 2026
4cb1539
Formatting
ds5678 May 1, 2026
44b07da
Make CodeGenParameter a record struct
ds5678 May 1, 2026
15b8cb2
Move ByRefWrapper to its own file
ds5678 May 1, 2026
4edc667
Small performance improvement
ds5678 May 1, 2026
66fd7b4
Replace IntPtr and UIntPtr with their keywords
ds5678 May 1, 2026
ca66425
CodeGenType
ds5678 May 1, 2026
801ed6a
Block-scoped namespace for interfaces
ds5678 May 1, 2026
dd55ed8
implement source generator for Il2Cpp type definitions (#9)
Atmudia May 1, 2026
151d44d
Struct generator generates interfaces too
ds5678 May 2, 2026
0e783d3
Source generator tests
ds5678 May 2, 2026
5671df1
Add InjectedTypePartialAnalyzer to validate decorated types and membe…
Atmudia May 2, 2026
c973fad
Analyzer testing framework
ds5678 May 2, 2026
878b0d4
Formatting
ds5678 May 2, 2026
cc6c772
Use Roslyn LinePositionSpan type
ds5678 May 2, 2026
8d2b571
Move GeneratePackageOnBuild to individual projects
ds5678 May 3, 2026
f58400a
Embed source generator in Il2CppInterop.Runtime package
ds5678 May 3, 2026
927978f
Move ResolveICall from IL2CPP to RuntimeInvoke
ds5678 May 3, 2026
a7ee96a
Remove xref implementation
ds5678 May 3, 2026
c4f0db3
Move FieldAccess, Il2CppType, and RuntimeInvoke out of the InteropTyp…
ds5678 May 3, 2026
91cc0e4
Remove NativeStructUtils from public API
ds5678 May 3, 2026
81d8fea
Move Il2CppToMonoDelegateReference to InteropTypes namespace
ds5678 May 3, 2026
5bb03ac
Fix namespace not getting changed
ds5678 May 3, 2026
9d81718
Minor cleanup to types in the injection namespace
ds5678 May 3, 2026
0b4fda7
Change MemoryUtils to SignatureDefinition
ds5678 May 3, 2026
1cada86
XrefScannerLowLevel -> XrefScanner
ds5678 May 3, 2026
33591ef
Delete Il2CppInterop.Runtime.InteropTypes.CoreLib namespace
ds5678 May 3, 2026
af4e8f0
Make Logger a public class and remove InternalsVisibleTo
ds5678 May 3, 2026
38a39e2
Move GetIl2CppMethod and GetIl2CppMethodByToken to GenerationInternals
ds5678 May 3, 2026
fe5d7b7
Use Regex source generation in GenerationInternals
ds5678 May 3, 2026
636dad9
Fix GetIl2CppValueSize spelling
ds5678 May 3, 2026
4d7ff81
Improve TrampolineHelpers performance
ds5678 May 3, 2026
9f0ffcd
Fix array initializer syntax and use nameof for MonoField
ds5678 May 3, 2026
9037b10
Update class struct generation for VTable
ds5678 May 3, 2026
f1c3b55
Update il2cpp_class_value_size to use out instead of ref
ds5678 May 3, 2026
38ad4c7
Fix bug in previous commit
ds5678 May 3, 2026
68b258c
Initial generic class inflation
ds5678 May 3, 2026
a431b63
Update NuGet dependencies to latest versions
ds5678 May 3, 2026
70b5269
Move Il2CppObjectPool to root in Il2CppInterop.Runtime
ds5678 May 3, 2026
fddd5d0
Refactor Il2CppObjectPool to not reference Il2CppSystem.Object
ds5678 May 3, 2026
811c1f0
Move IL2CPP to the Common project
ds5678 May 3, 2026
4c177ef
Ensure we're using the image name in the generation process
ds5678 May 3, 2026
96be259
Update il2cpp_domain_get_assemblies to use out param
ds5678 May 3, 2026
be05351
Merge Il2CppClassPointerStore into Il2CppType
ds5678 May 4, 2026
694ca6b
Fix incorrect unstripping of unbox and unbox.any
ds5678 May 5, 2026
9fa6b9c
Fix some naming issues with FieldAccess
ds5678 May 5, 2026
5707518
Validate that class pointer is only being set once
ds5678 May 5, 2026
0a3454c
Improved boxing support
ds5678 May 6, 2026
45daa0f
Fix issues unstripping box and unbox.any for Nullable<>
ds5678 May 6, 2026
7d9a987
Update source generation to account for changes in the IIl2CppType in…
ds5678 May 6, 2026
375d9f9
Fix trampolines in TypeInjector for value types
ds5678 May 7, 2026
b2576c5
Move Il2CppObjectPool and Il2CppType to Common project
ds5678 May 7, 2026
c9765c9
ObjectPointer.New<>()
ds5678 May 7, 2026
298829b
Automatic intializer registration
ds5678 May 7, 2026
71663c6
Use function pointers instead of delegates in Il2CppObjectPool
ds5678 May 7, 2026
f80ebbd
Slight name change
ds5678 May 7, 2026
6561b05
Unstrip TypedReference op codes
ds5678 May 7, 2026
a17400a
Fix method translation logging incorrect statistics
ds5678 May 7, 2026
a820001
Support using multidimensional arrays in unstripped method bodies
ds5678 May 7, 2026
11b802a
Unstrip ldelem_ref and stelem_ref
ds5678 May 7, 2026
2ae5774
Support ldind.ref and stind.ref in unstripping
ds5678 May 7, 2026
958d4e3
Avoid unnecessary nop instructions when unstripping method calls
ds5678 May 7, 2026
c02ce77
Free original method body after translation
ds5678 May 7, 2026
dcb7bfa
Fix bug in previous commit
ds5678 May 7, 2026
6ab43d2
Improve unstripping of calls to IObject, IValueType, and IEnum methods
ds5678 May 7, 2026
ac5979b
Fix signature for interface implementation in Nullable<T>
ds5678 May 7, 2026
2ec5956
Don't register initializers for abstract classes and interfaces
ds5678 May 7, 2026
6efc3eb
Enable operation without assemblies for unstripping
ds5678 May 8, 2026
2efc186
Remove temporary fix for interface base types
ds5678 May 8, 2026
70fc661
Remove ExpandMacros backport implementation
ds5678 May 8, 2026
7219f09
Add multiple diagnostic analyzers for Il2CppInterop injected types (…
Atmudia May 8, 2026
836c7f3
Update AssetRipper.Cpp2IL.Core to version 1.0.3
ds5678 May 8, 2026
8066b08
Formatting
ds5678 May 8, 2026
915fd77
Add empty processing layer for system interfaces
ds5678 May 9, 2026
bfb41b0
Replace comments with Debug.Fail calls
ds5678 May 9, 2026
543fb90
Move GetFullyQualifiedName to TypeInjector
ds5678 May 9, 2026
5f3acde
Performance improvements for ContextResolver
ds5678 May 9, 2026
fb6e736
Rename Il2CppInteropUtils -> Il2CppInternalsAccess
ds5678 May 9, 2026
4310a38
Rename source generator types
ds5678 May 9, 2026
d35b61c
Add static Null property to ByReference<T> and Pointer<T>
ds5678 May 9, 2026
16b63da
Minor comments and changes
ds5678 May 9, 2026
627a63d
Make INativeStructHandler::Size a property
ds5678 May 9, 2026
f903252
Update Il2CppArrayRank3 indexer to support 3 indices
ds5678 May 9, 2026
f24f475
Support 4D and 5D arrays
ds5678 May 9, 2026
0918175
Change Il2CppInterop.Runtime.Runtime namespace to Il2CppInterop.Runti…
ds5678 May 9, 2026
b3eff30
Change namespace for SignatureDefinition
ds5678 May 10, 2026
eb279fd
Move signature hashing logic from TypeInjector to separate files
ds5678 May 10, 2026
cc89576
Don't create useless maps in TypeInjector
ds5678 May 10, 2026
f40afca
Use SignatureHash for invokers instead of NamedSignatureHash
ds5678 May 10, 2026
a6b7b9d
Update XxHash128Extensions byte Append method
ds5678 May 10, 2026
a1b13c9
Refactor Il2Cppmscorlib access and remove static field
ds5678 May 10, 2026
b6d7c2c
File scoped namespace for hooking classes
ds5678 May 10, 2026
e633341
Refactor detour logic into Hook class
ds5678 May 10, 2026
2c33ec9
Remove InjectorHelpers and move its functionality to other classes
ds5678 May 10, 2026
ec3ae2f
Rename TrampolineHelper to TrampolineBuilder and make public
ds5678 May 10, 2026
57d0f9e
Rename SignatureHash to InvokerSignatureHash
ds5678 May 10, 2026
c2a6b00
Move GetOrCreateDelegateType to TrampolineBuilder
ds5678 May 10, 2026
7cf092e
Clean up TrampolineBuilder
ds5678 May 11, 2026
b2e6c0f
Unify trampoline creation
ds5678 May 11, 2026
96ea3e3
Fix issues with DelegateSupport
ds5678 May 11, 2026
2a1bbc0
Change some static abstract methods to static virtual so that they do…
ds5678 May 11, 2026
f30be5a
Make CI happy
ds5678 May 11, 2026
f3a26f9
Support primitives in user friendly overload generation
ds5678 May 11, 2026
6f9c7df
Refactor: remove GetCurrentAppContext() helper
ds5678 May 15, 2026
3f06452
Fix bug in delegate conversion processing layer
ds5678 May 15, 2026
fee79c2
Ensure delegate types always have addition and subtraction operators
ds5678 May 16, 2026
c844bc7
Only use Cpp2IL logger in generator
ds5678 May 16, 2026
ef4f0e5
Support generating overloads for "virtual" methods
ds5678 May 17, 2026
9e3ff52
Convert Il2Cpp delegates in user friendly overloads
ds5678 May 17, 2026
2f3e75e
Initial system interface implementation
ds5678 May 17, 2026
589ff0d
Refactor logging and processing layer setup
ds5678 May 17, 2026
4412acb
Fix NuGet issues related to Il2Cppmscorlib
ds5678 May 17, 2026
d391a63
Make system interfaces more complete and fix some bugs
ds5678 May 17, 2026
f3008ac
Fix nullable warnings for struct handler initialization
ds5678 May 17, 2026
a5a8463
Do not use preview language version
ds5678 May 17, 2026
48c2d37
Add <auto-generated /> to generated files
ds5678 May 18, 2026
fec313c
Suppress CS0649 warning in project file
ds5678 May 18, 2026
b07e22c
Nullable enable by default
ds5678 May 18, 2026
ea92344
Remove Configurations and Platforms from csproj files
ds5678 May 18, 2026
5425cbf
Add PackageId to csproj files and update packaging config
ds5678 May 18, 2026
0c53c28
Use Authors property from Directory.Build.props
ds5678 May 18, 2026
d235a49
Annotate project for AOT compatibility
ds5678 May 18, 2026
b83306b
Formatting
ds5678 May 18, 2026
1c9ef79
Correct documentation for IsInjected property
ds5678 May 18, 2026
5f5df58
Explicit conversion operator from the Il2Cpp delegate type to the man…
ds5678 May 18, 2026
f7cbf31
Update NuGet package versions across projects
ds5678 May 18, 2026
006e881
Use injected interfaces in SystemInterfaceProcessingLayer
ds5678 May 19, 2026
ca2af47
Include Il2Cppmscorlib.dll in NuGet package build
ds5678 Jun 16, 2026
8236f88
Update package versions: Cpp2IL.Core and PolySharp
ds5678 Jun 16, 2026
b45c79d
Fix source generator output for structs
ds5678 Jun 21, 2026
b6fdd26
Fix incorrect warning for fields in injected structs
ds5678 Jun 21, 2026
eafedbf
Make internal calls more intuitive and efficient
ds5678 Jun 21, 2026
6f0ecca
Add FromSystemType for System.Type to Il2CppSystem.Type
ds5678 Jun 22, 2026
61dfb87
Handle missing base interfaces in SystemInterfaceProcessingLayer
ds5678 Jun 22, 2026
81a92a2
Improve InvalidConstraintChecker
ds5678 Jun 22, 2026
41243ee
Rename obfuscated virtual methods
ds5678 Jun 22, 2026
6dcfb7b
Fix some structs having the abstract flag
ds5678 Jun 22, 2026
dddd983
Handle reference types inheriting from Il2CppSystem.ValueType
ds5678 Jun 22, 2026
c892e94
Implement UnboxNative on the Il2Cpp array types
ds5678 Jun 22, 2026
a540dd1
Fix IL2CPP string return P/Invokes (#13)
RaptorRush135 Jun 23, 2026
5a0a18c
Catch exceptions in Il2CppRuntimeClassInit
ds5678 Jun 23, 2026
ceca0bd
Fix null reference in FindClassInit
ds5678 Jun 23, 2026
6f9d7f8
Implement system for lazy type initialization
ds5678 Jun 24, 2026
a640f4b
Improve AOT annotations
ds5678 Jun 24, 2026
95f71e8
Source generate UnityVersionHandler initialization
ds5678 Jun 24, 2026
e55b1ef
Fix minor issue with previous commit
ds5678 Jun 24, 2026
85559c5
Push pending changes for Il2CppSystemTypeExtensions
ds5678 Jul 7, 2026
0ef3f8e
Add missing change
ds5678 Jul 7, 2026
49ab3d7
Fix outdated test
ds5678 Jul 8, 2026
cba4f57
Replace static virtual properties for naming with custom attributes
ds5678 Jul 8, 2026
6d1c19c
Push missing line
ds5678 Jul 8, 2026
6ffb765
Update versioned structs
ds5678 Jul 13, 2026
1f168bf
Update NuGet versions
ds5678 Jul 16, 2026
f46e88d
Unstrip field offsets for explicit layout structs
ds5678 Jul 19, 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
Loading