Comments (5)
Yes, I've been handling non-generic types without issue.
from asmresolver.
Did you verify that renaming non-generic fields poses no issues?
from asmresolver.
There is unfortunately nothing built in (yet) to do assembly level renaming/refactoring of symbols. You will have to do the renaming of related objects (i.e., member references) yourself.
That being said, you can get access to all member references in the module, even in high level mode. Have a look at e.g., ModuleDefinition::GetImportedMemberReferences
. For other types of members you can also query ModuleDefinition::LookupMember
or TryLookupMember
which takes arbitrary metadata tokens and attempts to resolve them to their representative IMetadataMember
object.
from asmresolver.
Thank you! The name GetImportedMemberReferences
(and GetImportedTypeReferences
) is kind of confusing; I thought "imported" referred to members defined outside of the module. Thanks for the hint with LookupMember
! (which is also kind of confusing, I guessed "type member" instead of "metadata member"). Looking at the source for the GetImported
methods I see that I can simply go through all of the RIDs, which is definitely good enough. Still, it would be nice to have first-class support for iterating through all (or at least a few more) of the other tables in high-level mode, though I understand why it isn't necessary for most use cases.
That aside, why is memberRef.Resolve()
returning null? Does the method only check if the ref's Parent is a TypeDef, ignoring TypeSpecs? If so, is that intended behavior? (I guess that makes sense, since TypeSpecs don't truly have members of their own and pointing to the original generic's member would be inaccurate). Anyway, thanks again for the help!
from asmresolver.
I thought "imported" referred to members defined outside of the module.
A member being imported merely means it is also present in the underlying MemberRef table. Whether it is an actual reference to an external member is not included in this definition. As you have seen with this example, a member reference can also refer to members in the current module.
Still, it would be nice to have first-class support for iterating through all (or at least a few more) of the other tables in high-level mode
There are two main reasons this was not done for all members. 1) Not all metadata tables have a representing IMetadataMember
(such as EventMap and PropertyMap). 2) To keep the API relatively simple, we did not want to add too many "convenience" methods to the public APIs, or else one cannot see the forest from the trees. That being said, I am open to suggestions on which helper methods should be added. You can of course also make your own extension methods to ModuleDefinition
that do these things for you if you need them. Indeed, it is just iterating over all metadata tokens and calling LookupMember on each of them.
That aside, why is memberRef.Resolve() returning null? Does the method only check if the ref's Parent is a TypeDef, ignoring TypeSpecs? If so, is that intended behavior? (I guess that makes sense, since TypeSpecs don't truly have members of their own and pointing to the original generic's member would be inaccurate). Anyway, thanks again for the help!
I cannot seem to reproduce this problem locally. Do you have a binary that you could share for which this is the case?
from asmresolver.
Related Issues (20)
- `Assembly.FullName` is not including `Culture=...` part HOT 1
- Writing modules that have TypeRefs defined in the same module results in a null ResolutionScope HOT 2
- .NET Runtime Contexts
- Use `EmptyErrorListener` as the Default Reader Error Handler HOT 4
- StackOverflow when trying to write a file after patching HOT 1
- Suppress BadImageFormatException HOT 6
- MemberCloner doesn't handle custom attribute arguments corresponding to cloned types HOT 1
- AsmResolver.Elf HOT 2
- Reading entry assembly in AppHost / SingleFileHost HOT 4
- Add IsReferenceOrContainsReferences Equivalent for ITypeDescriptors
- Just some questions HOT 23
- `IWin32Resource::WriteToDirectory` does not take sorting into account
- Allow language identifiers to be customized and preserved in `IconResource` HOT 1
- Add .NET 3.5 Targets HOT 2
- Not Work with Tinysharp HOT 2
- CI and Artifacts? HOT 1
- Nested type Sort Error? HOT 3
- Type comparison fails on two imported types with different scope but forward to the same type HOT 4
- GetHashCode for FunctionPointerTypeSignature is not implemented HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from asmresolver.