Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
564 commits
Select commit Hold shift + click to select a range
4e30b3c
Enable nullablePublicOnly C# feature
wtfsck Jun 15, 2019
376b4ab
Use ??=
wtfsck Jun 18, 2019
95635cb
Add TypeDef.IsEquivalent
wtfsck Jun 23, 2019
9891e5f
Update csproj file
wtfsck Jul 9, 2019
7a4ba2b
Ignore exceptions due to invalid chars, closes #283
wtfsck Jul 9, 2019
9139304
Use Module.ScopeName and not Module.Name, closes #284
wtfsck Jul 14, 2019
b4843c7
Use 'is null'
wtfsck Jul 14, 2019
b8a883b
Merge branch 'master' into cs8
wtfsck Jul 14, 2019
523d2eb
Remove unused usings
wtfsck Jul 16, 2019
e2e4761
Fix custom heaps check
wtfsck Jul 16, 2019
9cff912
Get nested System.Type's namespace, closes #286
wtfsck Jul 19, 2019
f742c11
Use latest sourcelink version
wtfsck Jul 22, 2019
89a093c
Update README.md
wtfsck Jul 28, 2019
f67f969
Update sln file to require VS2019
wtfsck Jul 28, 2019
e90652d
Add options to disable writing bodies, field data, win32/.NET resources
wtfsck Jul 31, 2019
efa88b6
Mono reader improvements
wtfsck Jul 31, 2019
2ed6c0c
Store it in other list
wtfsck Jul 31, 2019
6043d91
Mono: Use uncompressed stream if #- was found, even if there's a #~ s…
wtfsck Aug 1, 2019
5bf183e
Don't re-add standalonesig if it's already been added and it contains…
wtfsck Aug 11, 2019
1c2d878
Update README.md
wtfsck Aug 11, 2019
8ff66b5
Update appveyor.yml
wtfsck Sep 5, 2019
7cc9e18
Update SRE nuget package versions
wtfsck Sep 23, 2019
97a2a75
Update VS version in sln file
wtfsck Sep 23, 2019
57e5e78
Enable GitHub Actions
wtfsck Sep 24, 2019
48f8550
Update build files
wtfsck Sep 25, 2019
87a0d19
Remove appveyor
wtfsck Sep 25, 2019
37e6de6
Update build files
wtfsck Sep 27, 2019
eed0e7c
Allow overwriting of the dll name which should be imported (#281)
batzen Sep 28, 2019
2fe4dda
Remvoe consts
wtfsck Sep 28, 2019
16b99aa
Merge branch 'cs8'
wtfsck Sep 28, 2019
777c6f9
Update build files
wtfsck Sep 29, 2019
0e0a442
Update build files
wtfsck Oct 3, 2019
8a233b0
Update build files
wtfsck Oct 3, 2019
c3d660c
Update build files
wtfsck Oct 6, 2019
dedbdce
Remove .gitattributes
wtfsck Oct 6, 2019
d643694
Update build and csproj files
wtfsck Oct 7, 2019
3f4014d
Update build files
wtfsck Oct 9, 2019
1457fa1
Remove BOM
wtfsck Oct 12, 2019
66e6769
Use vswhere to locate msbuild
wtfsck Oct 15, 2019
427c4fd
Update CA type resolver, make sure the type is an original type in th…
wtfsck Oct 19, 2019
857b313
Add an option to enable optimized CA serialized type strings
wtfsck Oct 19, 2019
bebfe2e
Initialize asmResolver.DefaultModuleContext in CreateModuleContext()
wtfsck Oct 19, 2019
5fbb3b3
Update README
wtfsck Oct 19, 2019
05f1fd1
Update README.md
wtfsck Oct 20, 2019
b398460
Update XML doc comment
wtfsck Oct 20, 2019
5b870f6
Remove duplicate (case insensitive comparison) enum value (PowerShell…
wtfsck Oct 21, 2019
ff449af
Update corlib ref detection
wtfsck Oct 22, 2019
a0b58a6
Resolve the token using the module, closes #316
wtfsck Oct 25, 2019
ec31526
Bump version
wtfsck Oct 29, 2019
b8205cc
Add FUNDING.yml
wtfsck Nov 4, 2019
a6a84f3
Update FUNDING.yml
wtfsck Nov 13, 2019
bc68fbb
Update sourcelink
wtfsck Nov 30, 2019
6564f90
Update package refs
wtfsck Dec 3, 2019
ebd0585
Add more extension methods (#328)
CreateAndInject Dec 6, 2019
b5b4ef4
Remove ?
wtfsck Dec 6, 2019
8ea0a56
Prevent a TypeSpec ref loop, closes #331
wtfsck Dec 25, 2019
4dc2865
Update README
wtfsck Dec 25, 2019
38df36d
Bump version
wtfsck Dec 26, 2019
0a3c99c
Format default case
wtfsck Mar 17, 2020
7be3909
Can't get array lbounds/sizes, assume each dim is 0.., closes #346
wtfsck Mar 17, 2020
48f42fc
Update new file offset calculation, #345
wtfsck Mar 17, 2020
f652a91
Update README.md
wtfsck Mar 18, 2020
b8d5e0b
Improve IsPinvokeMethod
CreateAndInject Mar 11, 2020
bc691c4
Add readonly to DataReader.Slice()
wtfsck Mar 18, 2020
8079861
Don't include asm type names in attrs by default if the types exist i…
wtfsck Mar 18, 2020
ce7a762
Use switch expressions
wtfsck Mar 18, 2020
aa94592
Merge pull request #343 from CreateAndInject/master
wtfsck Mar 18, 2020
b97a464
Update GetRidList()
wtfsck Mar 18, 2020
d84c7cc
Fix Importer when importing FieldInfo/MethodInfo with generic owner, …
wtfsck Mar 20, 2020
46b3839
Update FindMethod/Field to allow PrivateScope if ref is from same module
wtfsck Mar 20, 2020
e41b5ca
Update DynamicMethodBodyReader, closes #298
wtfsck Mar 20, 2020
5a39273
Add a new DynamicMethodBodyReader option
wtfsck Mar 21, 2020
2f8ce28
Bump version
wtfsck Apr 16, 2020
1fbf080
Update docs
wtfsck Jun 18, 2020
f895c90
Update pkgref
wtfsck Jun 20, 2020
651e304
Support Unmanaged call conv
wtfsck Jun 29, 2020
d4a7085
Unescape Type.Name & Type.FullName, fix #370 (#382)
CreateAndInject Jul 22, 2020
650017d
Delete FUNDING.yml
wtfsck Aug 12, 2020
0a3bc81
Remove DefineConstants from csproj
wtfsck Aug 13, 2020
a842977
Support new Roslyn CDIs, closes #386
wtfsck Aug 14, 2020
7a01346
'=' should be an vaild char for TypeNameParser.ReadTypeRefNoAssembly()
yyjdelete Aug 13, 2020
0ddabb7
Merge pull request #387 from yyjdelete/patch
wtfsck Aug 15, 2020
b6edf63
Don't escape ReflectionNamespace, closes #377
wtfsck Aug 18, 2020
6500594
Add .NET sun machine types
wtfsck Aug 24, 2020
5a59528
Update build.yml
wtfsck Aug 29, 2020
a14ea62
Update build.yml
wtfsck Aug 29, 2020
f5c61bf
Add AnalysisLevel=latest
wtfsck Aug 31, 2020
98ea089
Support for custom/experimental CIL opcodes. (#378)
alexrp Sep 11, 2020
3532ba7
Update hidden this param type, closes #392
wtfsck Sep 14, 2020
5a170b3
Merge pull request #395 from 0xd4d/this_type_fix
wtfsck Sep 14, 2020
523c2d5
Update build.yml
wtfsck Oct 26, 2020
d547cdf
Use .NET 5.0 SDK
wtfsck Nov 10, 2020
756680e
Use latest C# version
wtfsck Nov 11, 2020
4e0837c
Use is not null
wtfsck Nov 11, 2020
1b7087f
Bump version
wtfsck Jun 23, 2021
634db70
ResolutionScope now actually can be null/0 in .NET 5 reference assemb…
echalone Jul 22, 2021
1787cd5
Preserve Log2Rid value when rewriting a module. (#416)
ElektroKill Jul 30, 2021
cfcdf54
Improve CAArgument analysis in MemberFinder
ElektroKill Jul 30, 2021
f7dc807
Merge pull request #417 from ElektroKill/ca-memberfinder
wtfsck Jul 30, 2021
75dc4d2
Add writing support for CAs and CDIs on manifest resources
ElektroKill Aug 2, 2021
9bb0af3
Add Resource.CustomAttributes to ModuleLoader
ElektroKill Aug 3, 2021
cd6e42b
Added support for reading CAs and CDIs on resources
ElektroKill Aug 3, 2021
85803e4
Merge pull request #418 from ElektroKill/ca-cdi-resources
wtfsck Aug 4, 2021
9814e5e
Add support for reading V1 resources (#419)
ElektroKill Aug 6, 2021
c20c724
Bump version
wtfsck Aug 24, 2021
08bb3b0
Analyze module resources in MemberFinder
ElektroKill Aug 30, 2021
8b14344
Merge pull request #420 from ElektroKill/fix/resources-memberfinder
wtfsck Aug 30, 2021
c25b455
Bump version
wtfsck Oct 20, 2021
1386325
Add ImporterOptions.TryToUseExistingAssemblyRefs option (#422)
wwh1004 Dec 5, 2021
ea4bb75
Show method name and token (#421)
CreateAndInject Dec 5, 2021
f21edfa
Improve rva/fileoffset conversion and ReadCilBody (#428)
wwh1004 Dec 6, 2021
22c0f1e
Update `.gitignore`
wtfsck Dec 6, 2021
c03a9e9
Update `.NET` refs to use `.NET Framework`
wtfsck Dec 6, 2021
9837109
Add `s390x` to `Machine` enum; add some props/methods
wtfsck Dec 6, 2021
76ab526
Add `PA_ARM64` to `AssemblyAttributes`, closes #425
wtfsck Dec 6, 2021
b9cfa62
Update exception handler type checks
wtfsck Dec 6, 2021
c2845c6
Update `CustomAttributeType` coded token table
wtfsck Dec 6, 2021
92c17da
Add `Metadata.GetLocal{Variable,Constant}RidList()`
wtfsck Dec 6, 2021
abb9fd6
`TypeDef` with rid 1 can't be a deleted type
wtfsck Dec 6, 2021
9a7f7f7
Support `#JTD` heap, closes #424
wtfsck Dec 6, 2021
2d1a918
Better mono support
wtfsck Dec 6, 2021
b656bf9
Update `InterfaceImpl` sorting, closes #426
wtfsck Dec 6, 2021
873ba1a
Support arm64 dia sym readers/writers
wtfsck Dec 6, 2021
49a0384
Add `allowTypeSpec` arg to `ReadType()`
wtfsck Dec 6, 2021
c8b150f
Use `Metadata.GetLocal{Variable,Constant}RidList()`
wtfsck Dec 6, 2021
086cda2
Remove old EH count code
wtfsck Dec 6, 2021
66e4a91
Bump version
wtfsck Dec 14, 2021
1a117dd
Update example to use `net6.0`
wtfsck Dec 16, 2021
78dadff
Enable deterministic csproj properties
wtfsck Dec 16, 2021
66e4105
Use .NET SDK 6.0.100
wtfsck Dec 16, 2021
abc7518
Merge pull request #434 from 0xd4d/net60
wtfsck Dec 16, 2021
a09639c
Merge branch 'master' into deterministic
wtfsck Dec 16, 2021
4a09c12
Merge pull request #433 from 0xd4d/deterministic
wtfsck Dec 16, 2021
842fc46
Update AssemblyRef.Attributes when updating AssemblyRef.PublicKeyOrTo…
CreateAndInject Dec 28, 2021
0c2a2df
Fixes https://github.com/0xd4d/dnlib/issues/438
wwh1004 Dec 28, 2021
acf49ee
Fixes TypeHelper.ContainsGenericParameter(MethodSpec)
wwh1004 Dec 28, 2021
237a0cb
Merge pull request #440 from wwh1004/fix3
wtfsck Dec 29, 2021
5b700d9
Merge pull request #439 from wwh1004/fix2
wtfsck Dec 29, 2021
8ed982f
Obfuscator may rename many methods/fields into same name then TryReso…
wwh1004 Dec 29, 2021
217a2ff
Use Module.ScopeName and case insensitive comparison
wwh1004 Dec 30, 2021
936bb3b
Fix infinite loop in SigComparer.GetHashCode(TypeSig)
wwh1004 Dec 30, 2021
63a06e6
Merge pull request #443 from wwh1004/fix1
wtfsck Dec 30, 2021
8f0b9ca
Use RuntimeInformation class to check environment.
ElektroKill Jan 7, 2022
62883b9
Merge pull request #449 from ElektroKill/fix/platform-check
wtfsck Jan 8, 2022
f4e084f
Validate data in case allocate too many memory, fix #442 (#448)
CreateAndInject Jan 8, 2022
b59cf33
Don't resolve 'T' which is already resolved
wwh1004 Jan 22, 2022
18d6c48
Fix 'Importer.Import(FieldInfo)' and 'Importer.ImportDeclaringType(Ty…
wwh1004 Jan 23, 2022
9ea8189
Merge pull request #452 from wwh1004/fix-importer
wtfsck Jan 31, 2022
2fae02e
Merge pull request #444 from wwh1004/fix4
wtfsck Jan 31, 2022
dafe486
Improve the error output that occurs when saving the module (#447)
wwh1004 Mar 24, 2022
aa403ba
Bump version
wtfsck Apr 9, 2022
3f856ae
Fix Importer and SigComparer‘s handling of generic when must treat ge…
wwh1004 May 28, 2022
7cad105
Merge pull request #466 from wwh1004/fix6
wtfsck May 29, 2022
a4afc15
Fix #468 Don't substitute type generic arguments when don't compare d…
wwh1004 May 30, 2022
ae6f88f
Merge pull request #469 from wwh1004/fix7
wtfsck Jun 9, 2022
6f4dc6f
Improvements to `DynamicMethodBodyReader` (#470)
ElektroKill Jun 17, 2022
bbbfb3c
Fix ArgumentOutOfRangeException
CreateAndInject Aug 13, 2022
7a9f0a3
Merge pull request #474 from CreateAndInject/ArgumentOutOfRange
wtfsck Aug 17, 2022
e58fbfc
Don't create wrong TypeSig for TypeDef
CreateAndInject Sep 10, 2022
e68aa72
Add support for new Roslyn CustomDebugInfo
ElektroKill Nov 11, 2022
4259413
Add support for boxed custom attribute arguments to `MemberFinder`
ElektroKill Nov 11, 2022
44ee7c8
Merge pull request #486 from ElektroKill/boxed-ca-memberfinder
wtfsck Nov 12, 2022
e666538
Add missing switch cases
ElektroKill Nov 12, 2022
45d6e88
Addressed feedback
ElektroKill Nov 15, 2022
5ac12c3
Addressed feedback
ElektroKill Nov 17, 2022
e43bd76
Merge pull request #485 from ElektroKill/new-roslyn-cdi
wtfsck Nov 18, 2022
97e07a8
Bump version
wtfsck Nov 19, 2022
b07706b
Add rudimentary support for `DeserializingResourceReader`
ElektroKill Jun 10, 2023
831661a
Support new `PrimaryConstructorInformationBlob` Roslyn CDI
ElektroKill Jun 10, 2023
07a11f9
Fixed `Resolver` for `null` `TypeRef.ResolutionScope`
ElektroKill Jun 25, 2023
a6c474f
Merge pull request #506 from ElektroKill/fix/resolver-null-resolution…
wtfsck Jul 8, 2023
ef4dce2
Add support for .NET 8.0 to `DynamicMethodBodyReader`
ElektroKill Jul 8, 2023
a41b1eb
Add support for reading `DynamicMethod`s created using `DynamicILInfo`
ElektroKill Jul 8, 2023
c0daec9
Merge pull request #503 from ElektroKill/new-roslyn-cdi
wtfsck Jul 9, 2023
c7de9fa
Merge pull request #508 from ElektroKill/dynamicmethod-reader-improve…
wtfsck Jul 9, 2023
7f916e3
Expose `WinMDHelpers` class
ElektroKill Jul 9, 2023
0b7109d
Merge pull request #511 from ElektroKill/expose-winmd-helpers
wtfsck Jul 9, 2023
f2b83cf
Add `DataStream` `Read` methods for signed integer types
ElektroKill Jul 9, 2023
5fc897a
Add `DataStream` `Read` methods for `char`, `bool`, and `decimal`
ElektroKill Jul 9, 2023
e636c16
Introduce proper read/write support for `DeserializingResourceReader`
ElektroKill Jul 10, 2023
1817790
Validate serialized resource data format when writing
ElektroKill Jul 10, 2023
2afeaee
Merge pull request #512 from ElektroKill/datastream-updates
wtfsck Jul 11, 2023
3f9c3e1
Address feedback
ElektroKill Jul 11, 2023
a91187d
Add another sanity check for V1 resources
ElektroKill Jul 12, 2023
3954fe6
Allow customizing of `ResourceDataFactory`
ElektroKill Jul 12, 2023
0549825
Added support for writing V1 resources
ElektroKill Jul 12, 2023
8eb5fae
Add option to specify format version when create a `ResourceElementSet`
ElektroKill Jul 12, 2023
b16eb80
Add `ResourceElementSet.Clone` method
ElektroKill Jul 12, 2023
29d4743
Merge pull request #504 from ElektroKill/fix/net5-resource-reader
wtfsck Jul 15, 2023
bb061dc
Add additional `net6.0` target framework
ElektroKill Jul 15, 2023
f3aa817
Resolve compiler warnings
ElektroKill Jul 15, 2023
c0ec4ef
Update NuGet packages to latest version
ElektroKill Jul 15, 2023
31b3d32
Merge pull request #479 from CreateAndInject/CheckValueType
wtfsck Jul 15, 2023
cc12bac
Prefer string interpolation over string concatenation
ElektroKill Jul 15, 2023
4940797
Resolve potential NREs found via code analysis
ElektroKill Jul 15, 2023
6014534
Improve Importer TryToUseTypeDefs
CreateAndInject Jul 11, 2023
be1b313
Merge pull request #515 from ElektroKill/net60-tfm
wtfsck Jul 18, 2023
32ad9d1
Merge pull request #513 from CreateAndInject/ResolveType
wtfsck Jul 18, 2023
e9549f3
Compare reference only for MemberDefs if they are from the same module
CreateAndInject Jul 20, 2023
af2f56a
Add DisableCompareReferenceOnlyForMemberDefsInSameModule
CreateAndInject Jul 22, 2023
8558fa7
Merge pull request #517 from CreateAndInject/CompareMemberDef
wtfsck Jul 22, 2023
1b988c4
Add setter for `ArrayWriter.Position`
ElektroKill Jul 31, 2023
b257e88
Add `IChunk.CalculateAlignment`
ElektroKill Jul 31, 2023
0f1399b
Use field initial value alignment defined in `PackingSize`
ElektroKill Aug 1, 2023
b6d5644
Fix incorrect `Math.Max` call
ElektroKill Aug 1, 2023
61dfaa2
Move `RoundUpToPowerOfTwo` to `Utils`
ElektroKill Aug 1, 2023
976a66d
Optimize implementations of `IType.Namespace` and `IType.TypeName`
ElektroKill Aug 2, 2023
8fac3fc
Merge `Utils.GetAssemblyNameString` into `FullNameFactory`
ElektroKill Aug 5, 2023
5339807
Implement basic reusage of `StringBuilder`
ElektroKill Aug 5, 2023
25ce6bf
Implementing sorting to `UniqueChunkList<T>`
ElektroKill Aug 5, 2023
241c1e5
Make `Instruction.GetArgumentType` consistent with `ParameterList`
ElektroKill Aug 5, 2023
6ab868a
Merge pull request #521 from ElektroKill/fix-instruction-getargumenttype
wtfsck Aug 5, 2023
d344770
Merge pull request #520 from ElektroKill/optimized-type-names
wtfsck Aug 5, 2023
c8ba765
Use stable sort in `UniqueChunkList<T>`
ElektroKill Aug 6, 2023
2c2aea0
Add sanity check to `CalculateRvasAndFileOffsets`
ElektroKill Aug 6, 2023
1727923
Remove alignment restriction for `FieldRVA` in `Metadata`
ElektroKill Aug 6, 2023
c2d5c9e
Merge pull request #518 from ElektroKill/field-initialvalue-alignment
wtfsck Aug 6, 2023
46c56d9
Bump version
wtfsck Aug 25, 2023
aa9ac47
Use latest actions/checkout and actions/setup-dotnet
wtfsck Aug 25, 2023
532a392
Replace faulty flag with `ReferenceCompareForMemberDefsInSameModule`
ElektroKill Sep 1, 2023
552d570
Add `CompareReferenceInSameModule` convenience properties
ElektroKill Sep 1, 2023
a5cce92
Merge pull request #525 from ElektroKill/fix-reference-compare-sigcom…
wtfsck Sep 2, 2023
efba133
Bump version
wtfsck Sep 2, 2023
aac31a1
Optimize finding CustomAttribute by a full name (#527)
AlanLiu90 Sep 20, 2023
185557c
Bump version
wtfsck Sep 22, 2023
0105e6b
Update Example6.cs
Y4er Oct 26, 2023
67396c0
Merge pull request #531 from Y4er/master
wtfsck Oct 27, 2023
1e2c8f9
Fix incorrect column sizes when writing portable or embedded PDB files
ElektroKill Nov 4, 2023
8a012e9
Merge pull request #532 from ElektroKill/fix/pdb-writer-incorrect-col…
wtfsck Nov 4, 2023
8f7edaf
Bump version
wtfsck Nov 5, 2023
a45d40c
Check overlaps
CreateAndInject Jan 15, 2024
83a0ac6
Merge pull request #536 from CreateAndInject/CheckOverlaps
wtfsck Jan 15, 2024
3426764
Bump version
wtfsck Jan 16, 2024
9247e2c
Clean moduleSearchPaths
CreateAndInject Jan 24, 2024
2cffa15
Merge pull request #540 from CreateAndInject/Clean-moduleSearchPaths
wtfsck Jan 24, 2024
99f4db9
Implement IMemberDef for ITypeOrMethodDef
CreateAndInject Jan 31, 2024
71946df
Merge pull request #542 from CreateAndInject/AddBaseInterface
wtfsck Jan 31, 2024
ce6995a
Sync ReturnParameter
CreateAndInject Mar 3, 2024
0b2dc95
Merge pull request #549 from CreateAndInject/SyncReturnParameter
wtfsck Mar 4, 2024
006c640
Add new `AllowByRefLike` generic parameter attribute (#557)
ElektroKill May 28, 2024
080d759
Sort `ExportedType` table when writing to comply with new ECMA Augments
ElektroKill May 29, 2024
1e0ec26
Merge pull request #559 from ElektroKill/sort-exported-type-table
wtfsck May 30, 2024
4f47c5e
`ModuleWriter` no longer ignores `Cor20HeaderOptions.EntryPoint` value
ElektroKill Nov 30, 2024
1229681
Fix CI
ElektroKill Nov 30, 2024
f618525
Merge pull request #564 from ElektroKill/fix/cor20-entrypoint-settings
wtfsck Nov 30, 2024
c78d296
Bump version
wtfsck May 15, 2025
a606e38
Fix potential infinite loop in `TryGetOriginalTargetFrameworkAttribute`
ElektroKill Sep 3, 2025
b3060d8
Merge pull request #567 from ElektroKill/fix/TryGetOriginalTargetFram…
wtfsck Sep 3, 2025
73a4119
Add support for `TypeAttributes.ExtendedLayout`
ElektroKill Nov 10, 2025
207e5e1
Merge pull request #570 from ElektroKill/extended-type-layout
wtfsck Jan 3, 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
  •  
  •  
  •  
112 changes: 112 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
root = true

[*]
charset = utf-8
#end_of_line =
indent_size = 4
indent_style = tab
tab_width = 4

[*.json]

[app.config]

[*.yml]
indent_size = 2
indent_style = space

[*.{proj,csproj,vbproj,props,targets,resx,vsixmanifest}]
indent_size = 2
indent_style = space

[app.manifest]
indent_size = 2
indent_style = space

[*.xml]

[*.xaml]
indent_style = space

[*.{cs,vb}]
insert_final_newline = true

dotnet_separate_import_directive_groups = false
dotnet_sort_system_directives_first = true
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_object_initializer = true:suggestion
dotnet_style_predefined_type_for_locals_parameters_members = true:none
dotnet_style_predefined_type_for_member_access = true:none
dotnet_style_prefer_auto_properties = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = false:suggestion
dotnet_style_qualification_for_event = false:suggestion
dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_property = false:suggestion
dotnet_style_require_accessibility_modifiers = never:info

[*.cs]
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents = true
csharp_indent_case_contents_when_block = false
csharp_indent_labels = flush_left
csharp_indent_switch_labels = false
csharp_new_line_before_catch = true
csharp_new_line_before_else = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_open_brace = none
csharp_new_line_between_query_expression_clauses = true
csharp_prefer_braces = false
csharp_prefer_simple_default_expression = true:suggestion
#csharp_preferred_modifier_order =
csharp_preserve_single_line_blocks = true
csharp_preserve_single_line_statements = true
csharp_space_after_cast = false
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_after_comma = true
csharp_space_after_dot = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_after_semicolon_in_for_statement = true
csharp_space_around_binary_operators = before_and_after
csharp_space_around_declaration_statements = false
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_before_comma = false
csharp_space_before_dot = false
csharp_space_before_open_square_brackets = false
csharp_space_before_semicolon_in_for_statement = false
csharp_space_between_empty_square_brackets = false
csharp_space_between_method_call_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_declaration_name_and_open_parenthesis = false
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses =
csharp_space_between_square_brackets = false
csharp_style_conditional_delegate_call = true:suggestion
csharp_style_deconstructed_variable_declaration = false:none
csharp_style_expression_bodied_accessors = true:suggestion
csharp_style_expression_bodied_constructors = true:suggestion
csharp_style_expression_bodied_indexers = true:suggestion
csharp_style_expression_bodied_methods = true:suggestion
csharp_style_expression_bodied_operators = true:suggestion
csharp_style_expression_bodied_properties = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
csharp_style_pattern_local_over_anonymous_function = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_throw_expression = true:suggestion
csharp_style_var_elsewhere = true:suggestion
csharp_style_var_for_built_in_types = false:none
csharp_style_var_when_type_is_apparent = true:suggestion

[*.vb]
#visual_basic_preferred_modifier_order =
78 changes: 78 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: GitHub CI
on:
push:
paths:
- '.github/workflows/**'
- 'Examples/**'
- 'src/**'
- '!**/*.md'
branches:
- master
pull_request:
paths:
- 'Examples/**'
- 'src/**'
- '!**/*.md'
branches:
- master
release:
types: released

env:
CI_REQ_DOTNET_SDK_VER: 6.0.100

jobs:
build-windows:
name: Build (Windows)
runs-on: windows-latest

steps:
- uses: actions/checkout@v3

- uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{env.CI_REQ_DOTNET_SDK_VER}}

- name: Build
shell: pwsh
run: |
$msbuildPath = Split-Path (& "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -requires Microsoft.Component.MSBuild -find MSBuild\Current\Bin\amd64\MSBuild.exe | Select-Object -First 1) -Parent
$env:PATH = $msbuildPath + ';' + $env:PATH
.\build.ps1

- name: upload-artifact doesn't support wildcards
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')
shell: pwsh
run: |
New-Item -ItemType Directory nuget_files > $null
Copy-Item src\bin\Release\*.*nupkg nuget_files

- uses: actions/upload-artifact@v4
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')
with:
name: nupkg
path: nuget_files
if-no-files-found: error

- name: Upload to nuget.org if it's a new release
if: startsWith(github.ref, 'refs/tags/')
shell: pwsh
run: |
Invoke-WebRequest -Uri https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -UseBasicParsing -OutFile nuget.exe
Get-ChildItem src\bin\Release\dnlib.*.nupkg | ForEach-Object { .\nuget.exe push $_.FullName -ApiKey ${{secrets.NUGET_APIKEY}} -NonInteractive -Source https://api.nuget.org/v3/index.json }

# Make sure it builds on Linux too
build-ubuntu:
name: Build (Ubuntu)
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{env.CI_REQ_DOTNET_SDK_VER}}

- name: Build
shell: pwsh
run: ./build.ps1
14 changes: 4 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
*~
*/obj/
*.csproj.user
*.sdf
*.opensdf
*.suo
/Debug/
/Release/
/Examples/bin/
*.tmp_proj
.vs/
.vscode/
bin/
obj/
12 changes: 6 additions & 6 deletions Examples/Example1.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using dnlib.DotNet;

namespace dnlib.Examples {
Expand All @@ -8,17 +8,17 @@ namespace dnlib.Examples {
public class Example1 {
public static void Run() {
// Load mscorlib.dll
string filename = typeof(void).Module.FullyQualifiedName;
ModuleDefMD mod = ModuleDefMD.Load(filename);
var filename = typeof(void).Module.FullyQualifiedName;
var mod = ModuleDefMD.Load(filename);

int totalNumTypes = 0;
// mod.Types only returns non-nested types.
// mod.GetTypes() returns all types, including nested types.
foreach (TypeDef type in mod.GetTypes()) {
foreach (var type in mod.GetTypes()) {
totalNumTypes++;
Console.WriteLine();
Console.WriteLine("Type: {0}", type.FullName);
if (type.BaseType != null)
if (type.BaseType is not null)
Console.WriteLine(" Base type: {0}", type.BaseType.FullName);

Console.WriteLine(" Methods: {0}", type.Methods.Count);
Expand All @@ -29,7 +29,7 @@ public static void Run() {

if (type.Interfaces.Count > 0) {
Console.WriteLine(" Interfaces:");
foreach (InterfaceImpl iface in type.Interfaces)
foreach (var iface in type.Interfaces)
Console.WriteLine(" {0}", iface.Interface.FullName);
}
}
Expand Down
18 changes: 9 additions & 9 deletions Examples/Example2.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using dnlib.DotNet;
using dnlib.DotNet;
using dnlib.DotNet.Emit;

namespace dnlib.Examples {
Expand All @@ -7,10 +7,10 @@ public class Example2 {
// and then save the assembly to disk.
public static void Run() {
// Open the current module
ModuleDefMD mod = ModuleDefMD.Load(typeof(Example2).Module);
var mod = ModuleDefMD.Load(typeof(Example2).Module);

// Create a new public class that derives from System.Object
TypeDef type1 = new TypeDefUser("My.Namespace", "MyType",
var type1 = new TypeDefUser("My.Namespace", "MyType",
mod.CorLibTypes.Object.TypeDefOrRef);
type1.Attributes = TypeAttributes.Public | TypeAttributes.AutoLayout |
TypeAttributes.Class | TypeAttributes.AnsiClass;
Expand All @@ -19,30 +19,30 @@ public static void Run() {
mod.Types.Add(type1);

// Create a public static System.Int32 field called MyField
FieldDef field1 = new FieldDefUser("MyField",
var field1 = new FieldDefUser("MyField",
new FieldSig(mod.CorLibTypes.Int32),
FieldAttributes.Public | FieldAttributes.Static);
// Add it to the type we created earlier
type1.Fields.Add(field1);

// Add a static method that adds both inputs and the static field
// and returns the result
MethodImplAttributes methImplFlags = MethodImplAttributes.IL | MethodImplAttributes.Managed;
MethodAttributes methFlags = MethodAttributes.Public | MethodAttributes.Static | MethodAttributes.HideBySig | MethodAttributes.ReuseSlot;
MethodDef meth1 = new MethodDefUser("MyMethod",
var methImplFlags = MethodImplAttributes.IL | MethodImplAttributes.Managed;
var methFlags = MethodAttributes.Public | MethodAttributes.Static | MethodAttributes.HideBySig | MethodAttributes.ReuseSlot;
var meth1 = new MethodDefUser("MyMethod",
MethodSig.CreateStatic(mod.CorLibTypes.Int32, mod.CorLibTypes.Int32, mod.CorLibTypes.Int32),
methImplFlags, methFlags);
type1.Methods.Add(meth1);

// Create the CIL method body
CilBody body = new CilBody();
var body = new CilBody();
meth1.Body = body;
// Name the 1st and 2nd args a and b, respectively
meth1.ParamDefs.Add(new ParamDefUser("a", 1));
meth1.ParamDefs.Add(new ParamDefUser("b", 2));

// Create a local. We don't really need it but let's add one anyway
Local local1 = new Local(mod.CorLibTypes.Int32);
var local1 = new Local(mod.CorLibTypes.Int32);
body.Variables.Add(local1);

// Add the instructions, and use the useless local
Expand Down
16 changes: 8 additions & 8 deletions Examples/Example3.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Text;
using dnlib.DotNet;
using dnlib.DotNet.Emit;
Expand All @@ -23,12 +23,12 @@ public class Example3 {
public static void Run() {
// Create a new module. The string passed in is the name of the module,
// not the file name.
ModuleDef mod = new ModuleDefUser("MyModule.exe");
var mod = new ModuleDefUser("MyModule.exe");
// It's a console application
mod.Kind = ModuleKind.Console;

// Add the module to an assembly
AssemblyDef asm = new AssemblyDefUser("MyAssembly", new Version(1, 2, 3, 4), null, null);
var asm = new AssemblyDefUser("MyAssembly", new Version(1, 2, 3, 4), null, null);
asm.Modules.Add(mod);

// Add a .NET resource
Expand All @@ -37,14 +37,14 @@ public static void Run() {
ManifestResourceAttributes.Private));

// Add the startup type. It derives from System.Object.
TypeDef startUpType = new TypeDefUser("My.Namespace", "Startup", mod.CorLibTypes.Object.TypeDefOrRef);
var startUpType = new TypeDefUser("My.Namespace", "Startup", mod.CorLibTypes.Object.TypeDefOrRef);
startUpType.Attributes = TypeAttributes.NotPublic | TypeAttributes.AutoLayout |
TypeAttributes.Class | TypeAttributes.AnsiClass;
// Add the type to the module
mod.Types.Add(startUpType);

// Create the entry point method
MethodDef entryPoint = new MethodDefUser("Main",
var entryPoint = new MethodDefUser("Main",
MethodSig.CreateStatic(mod.CorLibTypes.Int32, new SZArraySig(mod.CorLibTypes.String)));
entryPoint.Attributes = MethodAttributes.Private | MethodAttributes.Static |
MethodAttributes.HideBySig | MethodAttributes.ReuseSlot;
Expand All @@ -57,14 +57,14 @@ public static void Run() {
mod.EntryPoint = entryPoint;

// Create a TypeRef to System.Console
TypeRef consoleRef = new TypeRefUser(mod, "System", "Console", mod.CorLibTypes.AssemblyRef);
var consoleRef = new TypeRefUser(mod, "System", "Console", mod.CorLibTypes.AssemblyRef);
// Create a method ref to 'System.Void System.Console::WriteLine(System.String)'
MemberRef consoleWrite1 = new MemberRefUser(mod, "WriteLine",
var consoleWrite1 = new MemberRefUser(mod, "WriteLine",
MethodSig.CreateStatic(mod.CorLibTypes.Void, mod.CorLibTypes.String),
consoleRef);

// Add a CIL method body to the entry point method
CilBody epBody = new CilBody();
var epBody = new CilBody();
entryPoint.Body = epBody;
epBody.Instructions.Add(OpCodes.Ldstr.ToInstruction("Hello World!"));
epBody.Instructions.Add(OpCodes.Call.ToInstruction(consoleWrite1));
Expand Down
2 changes: 1 addition & 1 deletion Examples/Example4.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using dnlib.DotNet;
using dnlib.DotNet.Emit;

Expand Down
12 changes: 5 additions & 7 deletions Examples/Example5.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using System;
using System.IO;
using dnlib.DotNet;
using dnlib.PE;
using dnlib.IO;

namespace dnlib.Examples {
/// <summary>
Expand All @@ -16,7 +14,7 @@ public static void Run() {
var mod = ModuleDefMD.Load(typeof(int).Module);

// Get PE image interface
var peImage = mod.MetaData.PEImage;
var peImage = mod.Metadata.PEImage;

// Print some info
Console.WriteLine("Machine: {0}", peImage.ImageNTHeaders.FileHeader.Machine);
Expand All @@ -26,13 +24,13 @@ public static void Run() {
for (int i = 0; i < peImage.ImageSectionHeaders.Count; i++) {
var section = peImage.ImageSectionHeaders[i];

// Create a stream for the whole section
var stream = peImage.CreateStream(section.VirtualAddress, section.SizeOfRawData);
// Create a reader for the whole section
var reader = peImage.CreateReader(section.VirtualAddress, section.SizeOfRawData);

// Write the data to disk
var fileName = string.Format(sectionFileName, i);
Console.WriteLine("Dumping section {0} to file {1}", section.DisplayName, fileName);
File.WriteAllBytes(fileName, stream.ReadAllBytes());
File.WriteAllBytes(fileName, reader.ToArray());
}
}
}
Expand Down
Loading