Page 1 of 1

Un-Signing BEPU's Assembly

Posted: Sat Aug 30, 2014 6:44 pm
by kokkivos
Hey there,

Is it a bad thing if I un-sign BEPU's assembly?

I have been trying to wrestle MonoGame and BEPU together for a few hours now. I don't want to use the MathConverter strategy because I'm lazy, so I've been trying to get implicit operators to work. I added the operators I needed inside of the BEPUUtilities project, and referenced MonoGame inside of BEPUUtilities. When I build it like that, BEPU complains that MonoGame isn't a strongly named assembly, and won't build. I tried many things to sign MonoGame's assembly, but I mainly ran into a problem with its friend assemblies not building because of Public Key nonsense that I couldn't seem to get to work. So, I tested taking the signature off of BEPUPhysics, and now it will build.

So, is that a bad thing to do?

Re: Un-Signing BEPU's Assembly

Posted: Sat Aug 30, 2014 7:18 pm
by Norbo
Unsigning it is fine. Given that the private key used to sign the assembly is in the public repository, it doesn't exactly do much :)

The only reason it is signed to begin with is for convenience when trying to reference it from other strong named assemblies, with the assumption that any user who needs actual security will do what is required.

Re: Un-Signing BEPU's Assembly

Posted: Sat Aug 30, 2014 7:45 pm
by kokkivos
I see. Thank you for the quick reply!

Re: Un-Signing BEPU's Assembly

Posted: Sat Aug 30, 2014 10:03 pm
by kokkivos
In case anyone in the future is curious, here is how I ended up resolving all of my MonoGame / BEPUPhysics conflicts (when you have the source code for both projects):

I unsigned the BEPUik, BEPUphysics, and BEPUutilities projects (right click on the project, go to the "signing" tab, uncheck "sign the assembly").

I added a BEPUutilities reference to all of the MonoGame projects (including the "2MGFX" one).

And lastly, I added the needed implicit operators. As an example, I added this to the top of MonoGame's Vector3 class:

Code: Select all

       /// <summary>
        /// convert from bepu to xna vector3
        /// </summary>
        public static implicit operator Microsoft.Xna.Framework.Vector3(BEPUutilities.Vector3 bepuVec)
        {
            return new Microsoft.Xna.Framework.Vector3(bepuVec.X, bepuVec.Y, bepuVec.Z);
        }

        /// <summary>
        /// convert from xna to bepu vector3
        /// </summary>
        public static implicit operator BEPUutilities.Vector3(Microsoft.Xna.Framework.Vector3 xnaVec)
        {
            return new BEPUutilities.Vector3(xnaVec.X, xnaVec.Y, xnaVec.Z);
        }

Re: Un-Signing BEPU's Assembly

Posted: Sat Aug 30, 2014 11:39 pm
by snoozbuster
I'd like to warn you that you're going to run into trouble when using operators on the two types. For example:

Code: Select all

new Microsoft.Xna.Framework.Vector3(0, 1, 0) + new BEPUutilities.Vector3(1, 0, 0)
Will cause the compiler to complain about "ambiguous +"; it doesn't know whether to convert the XNA vector into a BEPU one and add or convert the BEPU one to XNA and add. You'll still need to use MathConverter for these scenarios or rebuild the vector.
I took the same approach as you; if I wasn't lazy I'd probably go back and add a constructor to the BEPU types that accepts a XNA type and just clones the data. Then I wouldn't need MathConverter as often (except for matrices).

Re: Un-Signing BEPU's Assembly

Posted: Sun Aug 31, 2014 3:09 pm
by kokkivos
This is true, and I still use MathConverter for a couple of things, but with this case you can simply cast the BEPU Vector3 to an XNA Vector3, since I have the implicit operators.