-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setter for PropertyDefinition.SetMethod and PropertyDefinition.GetMethod #168
Comments
Note: property and event methods can already be added and/or modified through the If we were to add this setter to these kinds of properties, what would happen when the property e.g. has multiple getters defined? (This is invalid metadata but technically possible) |
If a getter or setter method is present, the method marked as getter or setter should be overwritten. |
Changing Perhaps we should change the description of |
While your proposal is a solution, the problem is not worth a hacky one like this. I think people would get confused on why specifically getter/setter x is being treated the way it is (even if its the first occurence).
Changing the properties to collections is also very unintuitive as you said as well. The properties are not called I would leave this issue open for further proposals. |
I think these should stay as getter-only properties. They only return the first get/set method, and changing this would be a silent breaking change. Taking that into account, a setter would be unintuitive. However, I have a proposal: //needs a better name
public void ApplyGetterAndSetter(MethodDefinition? getMethod, MethodDefinition? setMethod)
{
//Check that declaring types are not null and the same?
Semantics.Clear();
if(getMethod is not null)
Semantics.Add(new MethodSemantics(getMethod, MethodSemanticsAttributes.Getter));
if(setMethod is not null)
Semantics.Add(new MethodSemantics(setMethod, MethodSemanticsAttributes.Setter));
} |
Side note: If we're going for something like this, then for consistency I think we should also add the equivalent for the add/remove/fire methods of an |
Problem Description
AsmResolver is currently lacking the ability to set the properties
SetMethod
andGetMethod
of a PropertyDefinition.Proposal
Implement a setter for the properties
SetMethod
andGetMethod
of a PropertyDefinition in order to be able to set get and set accessors of properties.Alternatives
A property can be replaced by its get and set accessors and a corresponding field to host the value.
Additional context
Missing setter for
![Missing setter in AsmResolver](https://camo.githubusercontent.com/7a5222948e29a16bf40b95b2cc1109fd572e8faa1af986ff83896d4d55045be9/68747470733a2f2f63646e2e646973636f72646170702e636f6d2f6174746163686d656e74732f3335323830363231303136363332353234392f3833333531363338363235363934353136322f756e6b6e6f776e2e706e67)
PropertyDefinition.GetMethod
in AsmResolver (current state):Existing setter for
![Existing setter in dnlib](https://camo.githubusercontent.com/f653fa66c8e6887a82cd5585e8f4a27fc79017f2ad6c4017cee6d6fc88f6a14a/68747470733a2f2f63646e2e646973636f72646170702e636f6d2f6174746163686d656e74732f3335323830363231303136363332353234392f3833333531363533313133353933383536302f756e6b6e6f776e2e706e67)
PropertyDef.GetMethod
in Dnlib (feature request):The text was updated successfully, but these errors were encountered: