-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
CallBuilder produces strange cast on call target, in case two very similar overloads are present #2741
Comments
The problem here is that there are two very similar methods defined in the base class protected bool SetPropertyValue<T>(string propertyName, ref T propertyValueHolder, T newValue);
protected bool SetPropertyValue(string propertyName, ref int propertyValueHolder, int newValue); The IL tells us that the generic overload should be used:
And while it would be sufficient to specify generic type arguments to disambiguate in this case, our algorithm is not clever enough to try that combination: ILSpy/ICSharpCode.Decompiler/CSharp/CallBuilder.cs Lines 991 to 1031 in 06039f2
We try the following things (in that order):
If steps 2/3 and 4 are swapped, then the produced code should just be: SetPropertyValue<int>("XpoTspecInsulInfo2021Id", ref _fXpoTspecInsulInfo2021Id, value); However, I think there are many cases where this change would make the code look a lot worse... especially if the method has more than one type argument, or the type argument is a generic type with multiple levels of nesting. |
@siegfriedpammer Seems no need to swap steps, since |
Accessing protected members from derived classes is perfectly fine. What do you mean? |
Ah, yes, sorry, you are right. That is definitely something that we should fix. Thanks for reporting. |
…when disambiguating calls to protected methods.
StrangeCast.zip
See XpoTspecInsulInfo2021:
There's
((PersistentBase)this)
, but there's no such issue in the other properties defined in the same typeThe text was updated successfully, but these errors were encountered: