Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with building for WSA #124

lazlo-bonin opened this issue Jan 17, 2017 · 1 comment

Issues with building for WSA #124

lazlo-bonin opened this issue Jan 17, 2017 · 1 comment


Copy link

@lazlo-bonin lazlo-bonin commented Jan 17, 2017

While trying to make my plugin compatible with WSA I've found some errors in the (brilliant!) fsPortableReflection class and missing Resolve calls elsewhere in FS.

First, in fsPortableReflection, using Linq is missing when USE_TYPEINFO is enabled. I suspect this is due to the using directive not having been wrapper in a preprocessor conditional and therefore getting removed by a Remove and sort usings command.

The usings should read:

using System;
using System.Collections.Generic;
using System.Reflection;

using System.Linq;

The method fsSerializer.RemapAbstractStorageTypeToDefaultType is missing the required Resolve calls. Here's my implementation of them:

private void RemapAbstractStorageTypeToDefaultType(ref Type storageType) {
    if ((storageType.Resolve().IsInterface || storageType.Resolve().IsAbstract) == false)

    if (storageType.Resolve().IsGenericType) {
        Type remappedGenericType;
        if (_abstractTypeRemap.TryGetValue(storageType.Resolve().GetGenericTypeDefinition(), out remappedGenericType)) {
            Type[] genericArguments = storageType.GetGenericArguments();
            storageType = remappedGenericType.Resolve().MakeGenericType(genericArguments);

    else {
        Type remappedType;
        if (_abstractTypeRemap.TryGetValue(storageType, out remappedType))
            storageType = remappedType;

The method fsSerializer.SetDefaultStorageType is also missing the Resolve calls:

public void SetDefaultStorageType(Type abstractType, Type defaultStorageType) {
if ((abstractType.Resolve().IsInterface || abstractType.Resolve().IsAbstract) == false)
throw new ArgumentException("|abstractType| must be an interface or abstract type");
_abstractTypeRemap[abstractType] = defaultStorageType;

The method UnityEvent_Converter.CanProcess is also missing Resolve calls:

    public override bool CanProcess(Type type) {
        return typeof(UnityEvent).Resolve().IsAssignableFrom(type.Resolve()) && type.Resolve().IsGenericType == false;

And finally, for a reason that completely eludes me (can't find the documentation for it anywhere), in fsProtableReflection.GetAttribute(MemberInfo, Type, bool), MemberInfo.GetCustomAttributes seems to return an IEnumerable<Attribute> instead of an object[] on WSA platforms, therefore making the length and index call throw errors. My temporary fix is simply to force it into an array:

var attributes = element.GetCustomAttributes(attributeType, /*inherit:*/ true).ToArray();

I realize now that this last fix moves the System.Linq dependency out of the preprocessor conditional I mentioned earlier.

Copy link

@nloewen nloewen commented May 15, 2017

Can you test with the latest code in Master? #136 should have fixed these issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants