martindevans / SupersonicSound

C# Wrapper For FMOD Studio
Other
29 stars 9 forks source link

.NET Framework version can be reduced to v4.0 #31

Open hozuki opened 8 years ago

hozuki commented 8 years ago

I'm working on a project which uses .NET Framework 4.0. I tried to install SupersonicSound via NuGet and received a 'Not supported' error. So I checked the source code and found out this solution uses .NET Framework 4.6.

I try to build SupersonicSound under v4.0 and there are errors: IReadOnlyList (introduced in v4.5) and Vector3 (using System.Numerics, this assembly has a v4.0 version but the type was introduced in v4.6).

Since v4.0 is pre-installed in Windows 7 and it is forward-compatible, I think if SupersonicSound can run under v4.0 it can be more widely used. To achieve this, I suggest writing our own implementation for IReadOnlyList (which is only used on arrays in this solution) and Vector3.

What do you think?

martindevans commented 8 years ago

IReadOnlyList

I just had a quick look at the usage of this and it appears to only be used internally. If that's correct it's probably best just to return the plain array and trust that the consumer isn't going to misbehave (i.e. mutate the array).

Vector3

This is the more annoying one - a vector type which is incompatible with everyone else is pretty useless! Is it possible to install the System.Numerics library and use it from .net4.0?

What do you think?

If it can be done in an ergonomic way I think it's a pretty cool idea. I'll be very happy to accept PRs :)

Actually this also gives me an interesting idea: I wonder what it would take to support .net core? That would give us support on a tonne of platforms.

hozuki commented 8 years ago

Yes, all the usages of IReadOnlyList are arrays. However the methods or fields are public. I haven't read the code completely, only the usage search result part, but if it is true that all the usages are internal, the declarations can be replaced with arrays, with careful maintenance. I think some members can be changed into private/internal ones. We'll see that later.

The System.Numerics.Vectors assembly (which contains the Vector3 structure) is now able to be referenced as a NuGet package. The package has a vast range of framework support. Sadly, for .NET Framework, it requires v4.5 at least. (Poor Windows 7 users, no built-in solutions for them.) It also supports .NET Core. (I'm curious that who uses FMOD under .NET Core. XD)

I'll try to make a pull request in several days when I'm free. Thank you for the reply. Cheers!

hozuki commented 8 years ago

I used System.Numerics.Vectors package and it only needs v4.5 now. But lowering to v4.0 seems meaningless because System.Numerics namespace only contains BigInteger and Complex in v4.0. Vector3 is introduced in v4.6 (or, by referencing the that package, using it on v4.5 is also possible). So the minimum version is v4.5 then. So IReadOnlyList<T>s can be untouched.

For .NET Core, there are a lot of type checks (especially Type.IsEnum) and attribute usages. Those are not supported by .NET Core yet, so extending to .NET Core is unlikely, for now, I think.