thelinuxlich / artemis_CSharp

Artemis Entity System Framework ported to C#
Other
342 stars 78 forks source link

Throw Exceptions on Bit overflow when Int32 is used #61

Closed Maximusya closed 10 years ago

Maximusya commented 10 years ago

There are conditional compilation symbols that force Artemis to use either Int32 or BigInteger types for ComponentType.Bit and EntitySystem.SystemBit:

#if XBOX || WINDOWS_PHONE || PORTABLE || FORCEINT32

But Bit generation is based on left-shift operation that do not cause overflow exceptions even if run in checked mode. So if a user adds 33rd ComponentType or 33rd EntitySystem - she will not get the expected Bit (ComponentType will get 0 Bit, EntitySystem will get 1 Bit - implementation details), and something may stuck or explode in the EntityWorld :)

Proposed changes:

Notes:

tpastor commented 10 years ago

agree with the changes but the travis build failed

https://travis-ci.org/thelinuxlich/artemis_CSharp/builds/15993474

tpastor commented 10 years ago

Target CoreCompile: Tool /usr/bin/dmcs execution started with arguments: /noconfig /debug:full /debug+ /optimize- /out:obj/Debug/ArtemisMonoUnitTests.dll ../Artemis_UnitTests/Component/TestBaseComponent.cs ../Artemis_UnitTests/Component/TestDerivedComponent.cs ../Artemis_UnitTests/Component/TestHealthComponent.cs ../Artemis_UnitTests/Component/TestPowerComponent.cs ../Artemis_UnitTests/Component/TestPowerComponentPoolable.cs ../Artemis_UnitTests/Extra/DummyPlaceHolder.cs ../Artemis_UnitTests/Program.cs ../Artemis_UnitTests/Properties/AssemblyInfo.cs ../Artemis_UnitTests/System/TestCommunicationSystem.cs ../Artemis_UnitTests/System/TestEntityComponentProcessingSystem1.cs ../Artemis_UnitTests/System/TestEntityComponentProcessingSystem2.cs ../Artemis_UnitTests/System/TestEntityProcessingSystem.cs ../Artemis_UnitTests/System/TestEntityProcessingSystem1.cs ../Artemis_UnitTests/System/TestEntityProcessingSystem2.cs ../Artemis_UnitTests/System/TestEntityProcessingSystem3.cs ../Artemis_UnitTests/System/TestNormalEntityProcessingSystem1.cs ../Artemis_UnitTests/System/TestNormalEntityProcessingSystem2.cs ../Artemis_UnitTests/System/TestNormalEntityProcessingSystem3.cs ../Artemis_UnitTests/System/TestIntervalEntitySystem.cs ../Artemis_UnitTests/System/TestProcessingSystem.cs ../Artemis_UnitTests/System/TestQueueHybridSystem.cs ../Artemis_UnitTests/System/TestQueueSystem.cs ../Artemis_UnitTests/System/TestQueueSystemCopy.cs ../Artemis_UnitTests/System/TestQueueSystemCopy2.cs ../Artemis_UnitTests/System/TestRenderHealthBarMultiSystem.cs ../Artemis_UnitTests/System/TestRenderHealthBarSingleHeavySystem.cs ../Artemis_UnitTests/System/TestRenderHealthBarSingleSystem.cs ../Artemis_UnitTests/Template/TestEntityTemplate.cs ../Artemis_UnitTests/TestBag.cs ../Artemis_UnitTests/TestEntityFactory.cs ../Artemis_UnitTests/TestGeneral.cs ../Artemis_UnitTests/TestTimeWaster.cs /target:library /define:"TRACE;DEBUG;MONO" /reference:./nunit.framework.dll /reference:/usr/lib/mono/4.0/System.dll /reference:/usr/lib/mono/4.0/System.Data.DataSetExtensions.dll /reference:/usr/lib/mono/4.0/Microsoft.CSharp.dll /reference:/usr/lib/mono/4.0/System.Data.dll /reference:/usr/lib/mono/4.0/System.Core.dll /reference:/home/travis/build/thelinuxlich/artemis_CSharp/Artemis_Mono/bin/Debug//Artemis_Mono.dll /reference:/usr/lib/mono/4.0/mscorlib.dll /reference:/usr/lib/mono/4.0/System.Xml.dll /reference:/usr/lib/mono/4.0/System.Numerics.dll /warn:4 ../Artemis_UnitTests/TestGeneral.cs(1077,45): error CS0122: Artemis.ComponentType.ComponentType()' is inaccessible due to its protection level /home/travis/build/thelinuxlich/artemis_CSharp/Artemis_Mono/bin/Debug/Artemis_Mono.dll (Location of the symbol related to previous error) ../Artemis_UnitTests/TestGeneral.cs(1084,46): error CS0122:Artemis.ComponentType.ComponentType()' is inaccessible due to its protection level /home/travis/build/thelinuxlich/artemis_CSharp/Artemis_Mono/bin/Debug/Artemis_Mono.dll (Location of the symbol related to previous error) ../Artemis_UnitTests/TestGeneral.cs(1096,32): error CS0122: Artemis.ComponentType.ComponentType()' is inaccessible due to its protection level /home/travis/build/thelinuxlich/artemis_CSharp/Artemis_Mono/bin/Debug/Artemis_Mono.dll (Location of the symbol related to previous error) ../Artemis_UnitTests/TestGeneral.cs(1121,37): error CS0246: The type or namespace nameSystemBitManager' could not be found. Are you missing a using directive or an assembly reference? ../Artemis_UnitTests/TestGeneral.cs(1122,40): error CS0246: The type or namespace name SystemBitManager' could not be found. Are you missing a using directive or an assembly reference? ../Artemis_UnitTests/TestGeneral.cs(1122,13): error CS0825: The contextual keywordvar' may only appear within a local variable declaration ../Artemis_UnitTests/TestGeneral.cs(1128,45): error CS0841: A local variable systemBitManager' cannot be used before it is declared ../Artemis_UnitTests/TestGeneral.cs(1135,46): error CS0841: A local variablesystemBitManager' cannot be used before it is declared ../Artemis_UnitTests/TestGeneral.cs(1147,17): error CS0841: A local variable `systemBitManager' cannot be used before it is declared Task "Csc" execution -- FAILED Done building target "CoreCompile" in project "/home/travis/build/thelinuxlich/artemis_CSharp/Artemis_Mono/ArtemisMonoUnitTests.csproj".-- FAILED Done building project "/home/travis/build/thelinuxlich/artemis_CSharp/Artemis_Mono/ArtemisMonoUnitTests.csproj".-- FAILED Task "MSBuild" execution -- FAILED

Maximusya commented 10 years ago

At last! Btw Mono tests compile Artemis assembly with BigInteger. Int32 usage is not being tested.