MDK-SE icon indicating copy to clipboard operation
MDK-SE copied to clipboard

Minifier causing errors when code had no errors before.

Open Tom-A-Roberts opened this issue 5 years ago • 9 comments

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

Tom-A-Roberts avatar Jul 06 '20 18:07 Tom-A-Roberts

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 avatar Jul 07 '20 00:07 Wicorel

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

Wicorel avatar Jul 07 '20 00:07 Wicorel

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 avatar Jul 07 '20 01:07 Tom-A-Roberts

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.

Tom-A-Roberts avatar Jul 07 '20 01:07 Tom-A-Roberts

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

Wicorel avatar Jul 07 '20 01:07 Wicorel

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 avatar Jul 07 '20 14:07 malware-dev

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

malware-dev avatar Jul 07 '20 14:07 malware-dev

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.

Tom-A-Roberts avatar Jul 07 '20 14:07 Tom-A-Roberts