-
Notifications
You must be signed in to change notification settings - Fork 8
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
Update PXOverride diagnostic's messaging to indicate that a signature was not found #504
Comments
Hi @ShadowFiendZX . Regarding your suggestion:
We cannot list all extensions in the error message because the list of base extensions can be arbitrary long. Moreover, the for each level of chained graph extensions (except the last one) we should take into account base graph extensions. For example: public class MyGraph : PXGraph<MyGraph> { }
public class GraphExt1stLvl : PXGraphExtension<MyGraph> {}
public class DerivedGraphExt1stLvl : GraphExt1stLvl {}
public class GraphExt2ndLvl : PXGraphExtension>DerivedGraphExt1stLvl, MyGraph> {}
public class DerivedGraphExt2ndLvl : GraphExt2ndLvl {}
// and so on We can distinguish the case when there is no method to override form the signature mismatch. Perhaps, it will make the diagnostic more convenient, But we won;t list names of all base extensions. |
@ShadowFiendZX I have a feeling that what you really need is not the enhancement of this diagnostic but another check that will validate that graph extension does not pass itself to the list of base extensions. If yes, then please create another issue for such diagnostic. |
@SENya1990 I've created this issue requesting a new diagnostic for the circular reference mistake. I'm not really sure that the change I've requested here would be as useful if the other new diagnostic is created, since in that case with this diagnostic's current message you'll probably look at the base method either way, and would eventually realize you misnamed your PXOverride. |
I made just made a mistake in my PXGraphExtension hierarchy that led to me getting the new diagnostic error about a PXOverride signature mismatch. (Although I don't remember updating Acuminator recently, as I install it by building it locally ever since I first starting contributing, and I'm rather embarrassingly out of date)
To put it simply, my implementation was something like this :
In this case I got the error
The signature of a method with the PXOverride attribute must match the overridden method
While it is a problem that I made my 2nd extension extend itself, which would've likely led to errors when loading Acumatica, and might be an idea for a new diagnostic in itself, it took me a few minutes of staring at all my code to realize what I did wrong.
I think it'd be a little more helpful if the analyzer in this case would say something like
A method with this name was not found in the base graph or referenced graph extensions "APPaymentEntryExtension2".
This would be a separate case from a signature mismatch.The original error would still show if a method with that name was found, but like the error states, it'd show when there is a signature mismatch, just not when the signature is missing entirely.
However, I'm not sure how easy this would be, as I'm not sure if Acumatica supports PXOverriding methods from other extensions that aren't directly referenced in the extension list PXGraphExtension<...>.
I'm also not sure how this would pan out for generic classes, as I haven't looked into whether or not analyzers can (or do) resolve generic parameters.
For example :
If this is not possible, feel free to close this issue, I was just hoping there'd be some way to help others more quickly resolve the mistake I made.
The text was updated successfully, but these errors were encountered: