Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Minifier causing errors when code had no errors before. #199

Closed
Tom-A-Roberts opened this issue Jul 6, 2020 · 10 comments
Closed

Minifier causing errors when code had no errors before. #199

Tom-A-Roberts opened this issue Jul 6, 2020 · 10 comments
Assignees

Comments

@Tom-A-Roberts
Copy link

Tom-A-Roberts commented Jul 6, 2020

The code didn't initially have errors when compiling in SE. However when I compile in SE after minification, lots of errors appear:

image

These errors seem to be nearly all methods not found. Perhaps it isn't minifying method names where it should?
MDK project here if you wanna take a quick snoop to see if I'm doing something wrong:
https://github.com/ksqk34/Autodocking-2

@Wicorel
Copy link
Collaborator

Wicorel commented Jul 7, 2020

I'm guessing it's because it's a static class function.
public static double VectorAngleBetween(Vector3D a, Vector3D b) //returns radians { if (a.LengthSquared() == 0 || b.LengthSquared() == 0) return 0; else return Math.Acos(MathHelper.Clamp(a.Dot(b) / a.Length() / b.Length(), -1, 1)); }

Comes out as:

public static double ð(Vector3D ï, Vector3D î) { if (ï.LengthSquared() == 0 || î.LengthSquared() == 0) return 0; else return Math.Acos(MathHelper.Clamp(ï.Dot(î) / ï.Length() / î. Length(), -1, 1)); }

but reference is not (obviously) using the minified name.

Also, the code generated is not a crazy minified as I'm used to..

@Wicorel
Copy link
Collaborator

Wicorel commented Jul 7, 2020

Hmm. the CODE tagging removes some of the white space.. hrmph.

@Tom-A-Roberts
Copy link
Author

So you think it could be just an issue with static methods? That's a fairly easy fix if that's the case. I'll just turn them all into standard methods as I can find an instantiated version of the classes in all cases.

@Tom-A-Roberts
Copy link
Author

I have tested that, I removed all static methods, turning them into standard ones. This didn't help I'm afraid, it seems to be an issue with standard methods too.

@Wicorel
Copy link
Collaborator

Wicorel commented Jul 7, 2020

On reload/rebuild the minified code from your project looks nominal:

(I took out the preserve region for testing)
image

It's pasting the code back into VS that auto-formats it..
(I'm using Visual Studio 2017).

It still gets the same error.

My minified code looks like this:
image

@malware-dev malware-dev self-assigned this Jul 7, 2020
@malware-dev
Copy link
Owner

Interesting.

All I did was run a Resharper Cleanup Code on your project... and it generated correctly.

There is something about the way you write your code that is nonstandard.

@malware-dev
Copy link
Owner

I'm sorry I don't have the energy to figure out the details of how and why this works... but it does. Enclosing the fixed project. Maybe you can figure it out yourself? Or someone else interested?

Autodocking-2-fixedmaybe.zip

@Tom-A-Roberts
Copy link
Author

Tom-A-Roberts commented Jul 7, 2020

Thanks for the fixed files.
I think I'll download Resharper too.
I'll see what changes it makes and maybe I'll gain some insight into the crucial differences. I'm glad there is a fix though.

Thanks for your time on this Malware and Wicorel.

@skiittz
Copy link

skiittz commented Jan 28, 2023

I may have a guess as to what is going on.

I started out writing my script using classes nested in partial class Program definitions, as I thought this was necessary to work in the programmable block.

After running into inconsistent accessibility issues and reading another thread, I learned this was not necessary and refactored my code to put all my base classes into the namespace.

But I forgot to remove the partial class declaration from the actual Program.cs. Resharper caught that this was the only declaration of Program and thus the partial designation was not required and removed it.

So my best guess is that declaring a class as partial but then not actually having partial implementations is throwing of the brace placement in the minified code.

@malware-dev
Copy link
Owner

Closing because this site is being archived due to complete replacement at https://github.com/malforge/mdk2. If issue persist, please create new issue there.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants