Skip to content
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

New diagnostic to prevent circular extension hierarchies #505

Open
ShadowFiendZX opened this issue Jun 23, 2023 · 0 comments
Open

New diagnostic to prevent circular extension hierarchies #505

ShadowFiendZX opened this issue Jun 23, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@ShadowFiendZX
Copy link
Collaborator

The use case would be a possibly niche case, but would allow developers to more quickly realize the mistake they made before compiling and loading Acumatica.

See the below example code :

// Acumatica's graph.
public class APPaymentEntry : PXGraph<APPaymentEntry>
{
}

// Arbitrary extension 1.
public class APPaymentEntryExtension1 : PXGraphExtension<APPaymentEntry>
{
    public virtual void DoSomething()
    {
    }
}

// 2nd extension that I accidentally made extend itself due to lazily relying on VS autocomplete.
public class APPaymentEntryExtension2 : PXGraphExtension<APPaymentEntryExtension2, APPaymentEntry>
{
}

As you can see, I accidentally made APPaymentEntryExtension2 extend itself instead of APPaymentEntryExtension1. I'm not really sure how often this happens to others, but when you're pumping out code and using autocomplete, sometimes mistakes happen.
Eventually, you may either run into a PXOverride signature mismatch error like stated here, however, if you're not writing PXOverrides you might not, and would then make it to compilation, and loading Acumatica.
When Acumatica reloads, you'll get this error which should set you on the right path, although it mentions cache which might lead you to look at your DAC Extensions :
image
w3wp.exe will then crash, and VS will ask if you want to open the Just-In-Time Debugger.

However, I believe that adding a diagnostic to Acuminator will speed up the resolution of the bug not only because you won't have to wait for Acumatica to reload, but it'll also just tell you exactly where you made the mistake.

I would imagine that such a check would also be useful for DAC Extensions, although I haven't tested what happens when you make the same mistake in one, so I don't have a screenshot of the error you'd get when Acumatica loads.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant