Age | Commit message (Collapse) | Author |
|
Add arcade infrastructure to dotnet/cecil
Adds eng/common folder from arcade
Adds NuGet.config file with the dotnet eng/tools/public package sources
Adds build scripts at root level to execute the eng/common/build scripts
Adds eng/Versions.props and eng/Version.Details.xml files with minimal dependencies since Cecil doesn't require anything, mostly just setting up the package version
Adds global.json
Adds arcade artifacts to .gitignore file
Add Microsoft.Dotnet.Arcade.Sdk
Make Mono.Cecil a package
Remove frameworks non-compatible with Arcade SDK
Make the package non-shippable so it doesn't publish in Nuget
Suppress license validation since Cecil has a different license than MIT one
Workaround the publickey and publickey token generation from arcade
Modify version to match Cecil version 0.11.4.0
Remove helix SDK since we don't use helix testing
Add pipeline yaml file
Add support for NetCoreAppToolCurrent equals to net7.0 and ToolsFramework netstandard 2.0
Add a variable to find the resources folder given that there is a new structure in the artifacts directory
Use VS test runner to avoid running tests using xunit
Add signing properties for 3rd party libraries
|
|
* Address issue #873
* Be explicit as to what we support writing
* Use normal test infrastructure
* Restore writing primitives
* Restore style
* Can't verify .net core assembly
Co-authored-by: Jb Evain <jb@evain.net>
|
|
* ILProcessor should also update custom debug info (#34)
* ILProcessor should also update custom debug info
When eidting IL with ILProcessor various pieces of debug information have references to the origin IL instructions. These references can be either resolved (point to Instruction instance), in which case the editting mostly works, or unresolved (store IL offset only) in which case they need to be resolved before the editting can occur (after the edit the original IL offsets are invalid and unresolvable).
This is effectively a continuation of https://github.com/jbevain/cecil/pull/687 which implemented this for local scopes. This change extends this to async method stepping info and state machine scopes.
The change refactors the code to make it easier to reuse the same logic between the various debug infos being processed.
Updated the existing tests from https://github.com/jbevain/cecil/pull/687 to include async and state machine debug info (completely made up) and validate that it gets updated correctly.
* PR Feedback
Renamed some parameters/locals to better match the existing code style.
* PR Feedback
* Fix test on Linux
Native PDB is not supported on Linux and the test infra falls back to portable PDB automatically. Since the two PDB implementations read the custom debug info from a different place the test constructing the input needs to adapt to this difference as well.
|
|
entries. (#869)
Basically the first two entries are written correctly, and any after that which has data will have the RVA correct, but the virtual address field will be wrong. Depending on the consumer this can work (if they use RVA) or fail (if they use virtual address) as they would read garbage data.
Currently this mostly affects embedded protable PDBs since in that case we write 4 headers: CodeView, PdbChecksum, EmbeddedPdb and Deterministic (in this order), so the embedded PDB data is effectively wrong.
Also adds a test which validates that both the RVA and virtual address point to the same thing.
|
|
* Add support for generic attributes
* Compile test assembly against mscorlib
To satisfy PEVerify
|
|
* Fix custom attribute with enum on generic type
Fixes both the reader and the write to correctly handle values of type enum on a generic type.
Cecil represents generic instantiations as typeref which has etype GenericInst, so the exising check for etype doesn't work. Also since attributes only allow simple values and enums (and types), there's technically no other way to get a GenericInst then the enum case.
Added several test for various combinations of boxed an unboxed enums on generic type.
Added a test case provided by @mrvoorhe with array of such enums.
* Disable the new tests on .NET 4
The CodeDom compiler doesn't support parsing enums on generic types in attributes (uses the "old" csc.exe from framework).
|
|
* Fix deterministic MVID and add PdbChecksum (#31)
* Fix how pdb path is calculated in the tests
* Fix portable PDB stamp in CodeView header (#32)
* Introduce ISymbolWriter.Write
This mostly cleans up the code to make it easier to understand. `ISymbolWriter.GetDebugHeader` no longer actually writes the symbols, there's a new `Write` method for just that.
The assembly writer calls `Write` first and then the image writer calls `GetDebugHeader` when it's needed.
This is partially taken from https://github.com/jbevain/cecil/pull/617.
|
|
* Harden debug scope update logic
Based on bug reports like #816 it seems there are still cases where the IL and scope offsets are out of sync in weird ways. This change modifies the logic to have no potential to cause the `IndexOutOfRangeException`. While I was not able to determine what combination could cause this, it's better this way.
The corner case comes when there's potential problem with the first/second instruction in the method body. The change in this case will potentially make the debug scopes slightly wrong by not pointing to the previous instruction (as there's none). Without having a real repro it's hard to tell what would be a better solution, this way it won't crash and the scopes still make sense.
* Fix typo
|
|
* FieldRVA alignment
In support of dotnet/runtime#60948 the linker (an assembly rewriter) will need to be able to preserve the alignment of RVA based fields which are to be used to create the data for `CreateSpan<T>` records
This is implemented by adding a concept that RVA fields detect their required alignment by examining the PackingSize of the type of the field (if the field type is defined locally in the module)
* Update Mono.Cecil.Metadata/Buffers.cs
Co-authored-by: Aaron Robinson <arobins@microsoft.com>
* Enhace logic used to ensure type providing PackingSize is local to the module.
Co-authored-by: Aaron Robinson <arobins@microsoft.com>
|
|
* Pose the problem
* Quick and v dirty fix
* A better and more targeted fix (to fix the previous fix)
|
|
|
|
|
|
|
|
entries (#770)
|
|
* add failing test
* Fix resolving from netmodules
Co-authored-by: Jb Evain <jb@evain.net>
|
|
* Implement automatic handling of the HasFieldRVA field attribute.
Fixes #728
* Add FieldDefinition.HasFieldRVA
Co-authored-by: Jb Evain <jb@evain.net>
|
|
* Fix reading GenericInst constants in portable pdbs
* Add test
|
|
We are going to use this to do a multi stage load in parallel. We will be able to greatly reduce our load times using this new API. The way it's going to work is
Stage 1 - In parallel, load the assemblies with ReadingMode.Deferred.
Stage 2 - Populate our AssemblyResolver with a cache of all read assemblies.
Stage 3 - In parallel, call ImmediateRead.
What I really want is an API to load everything in stage 3. I found that ImmediateRead does not load method bodies. I don't know if/how you want want something like this exposed via the public API. For now I'm iterating the data model and forcing things to load that ImmediateRead did not cover.
|
|
* Revert "Refactor AddLayoutInfo"
This reverts commit 6070fe78e62b743eaed7bb9a6675f8170e4e27e6.
* Revert "Add a ClassLayoutTable row for structs with no instance fields"
This reverts commit 8f2b91726578075e4fb49d6d5759c4cd4495d0a5.
|
|
attribute is put on a method in a projected type. (#722)
Co-authored-by: Tautvydas Žilys <tautvydas.zilys@gmail.com>
|
|
* Allow removing value of ModuleDefinition::EntryPoint
* PR feedback
|
|
* Provoke the issue
* Minimum fix
(cherry picked from commit 0f23047c62027e10206a5d0dbb81cba6f2dc260f)
* Revert "Provoke the issue"
This reverts commit 1a2275b7f6704298fa386fa416c91bb09f0368bf.
* Add unit test
(cherry picked from commit 185ba884111e30cfb84aeb64f00324d995cfdd35)
* Use existing infrastructure
* Quick fix
Co-authored-by: Jb Evain <jb@evain.net>
|
|
Co-authored-by: Jb Evain <jb@evain.net>
|
|
This reverts commit 191f9fc0a79a138fdb634fbb51cf836a86b4e565.
|
|
* When I try to use ReadSymbols in a Module that is already created, for example:
var symbolReader = portablePdbReaderProvider.GetSymbolReader(asm.image, stream);
asm.image.ReadSymbols(symbolReader);
method.debug_info has a list, but it's empty, so it wasn't entering in the if, but it should, maybe we should change de if to method.debug_info == null || method.debug_info.count = 0.
* Adding test.
* Fix styling.
* Typo
Co-authored-by: Jb Evain <jb@evain.net>
|
|
* Better way to update local scopes when method bodies are editted
This change will make sure that all local scopes are resolved (they refer to instructions directly and don't rely on instruction offset alone) then fixup local scopes by simply updating instruction references.
Added better tests to validate that the behavior is correct across PDB write/read and some variations of the resolved/unresolved scopes behavior.
* Fix crash with null local scope
|
|
* Implemented Windows Runtime projections for implemented interface overrides.
* Don't redirect Windows Runtime projected methods on interfaces.
* Add additional test cases for Windows Runtime interface projection.
* Fix reading interface impl attributes when using immediate reading mode.
* Do not project for windows runtime during read.
A type will not be fully initialized during read, so don't attempt to
project for Windows runtime until after all of the metadata reading is
correct.
If a type reading for a module is no completed, a call to
BinaryRangeSearch in MetadataSystem can fail, because some of the
entries in the types array will still be null.
* Fix build warnings.
* Remove method that got duplicated during a cherry pick.
* Fixed an issue with MethodReferenceComparer where it would incorrectly identify two method references to be the same if they had the same declaring types, the same parameter counts and were both unresolvable.
* Sync up latest changes to MethodReferenceComparer and TypeReferenceEquality comparer and also add tests for them.
* Fix code formatting.
* Remove extra char
* Style fix
Co-authored-by: Ignas Ziberkas <ignas@unity3d.com>
Co-authored-by: Josh Peterson <petersonjm1@gmail.com>
Co-authored-by: Jb Evain <jb@evain.net>
|
|
* Automatically update local variable debug info
When manipulating the local variables collection on a method body, automatically update the debug info for all affected local variables.
When removing a local variable, also remove the debug info for that local variable from the scopes.
When removing or inserting update the indeces of local variable debug infos which are afected by the action. Note the local variable debug info either holds just a backpointer to the local variable in which case it doesn't store the index at all (and thus nothing to do), or it stores the index explicitly in which case it needs to be updated.
Added tests for both insert and remove cases.
* Add internal properties on `VariableOffset` to make it easier to manipulate it.
Reworked the `UpdateVariableIndeces` to only loop over variables once and also to handle removal of resolved variable debug infos.
* Simplify the code a little and add comments
* PR feedback
|
|
* Auto update local scopes in debug info when manipulating instructions
Before this change Cecil would not update local scopes when manipulating mehod bodies. This can lead to corrupted debug info - which when written to a PDB results in corrupted PDB.
Cecil can store local scopes in two ways:
* Using IL offset numbers - this is how pretty much all of the symbol readers populate the OMs.
* Using references to instructions.
If the local scopes use offset values this change will update the local scopes for all insert and remove operations on the method body. The behaviors for insert is basically "insert after" in that the new instruction is added to the scopes of the previous instruction.
If the local scopes are using instructions directly the change only removes any references to instructions which are being removed from the method body (and replaces them with the instruction offset value).
To be able to tell the difference between these cases the instruction field has been made internal in the InstructionOffset structure.
* Add `IsResolved` to the `InstructionOffset` to make the code more readable.
Note: Still have to keep the `instruction` field visible to handle the case of removing a resolved instruction offset reliably (since most resolved instructions will have the numerical offset 0).
* Add internal property on `InstructionOffset` to be able to keep all its fields private.
* Improve comments in the code.
|
|
|
|
* Changing GetSymbolReader from PdbReaderProvider, when we create a Module from stream we don't have the filename, and it's not necessary to create an EmbeddedPortablePdbReaderProvider, so I've moved the check to after the creation of EmbeddedPortablePdbReaderProvider.
|
|
* add failing test for LocallyScopedConstantArray
* add LocallyScopedConstantArray target assembly
* ElementType.Array should be treated the same as object in ReadLocalConstant
* assert constant is null
* Style fixes
Co-authored-by: Jb Evain <jb@evain.net>
|
|
This makes it simpler to work with it when the instruction positions
are known in advance.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|