Before I begin, a couple prefaces:
1. It's possible this is a duplicate/related issue to #3778. It seems different at a glance though so I just want to make sure.
2. The issue (I think anyway) is specific to configuration in bridge.json and I don't see any way on Deck.net to change these things, so I don't have a link for you there. Sorry. I will paste the code below though
The problem:
When the project is compiled as a `UMD` or `CommonJS` module, dictionary methods are throwing Javascript errors. Here's some code that should reproduce the problem:
1. It's possible this is a duplicate/related issue to #3778. It seems different at a glance though so I just want to make sure.
2. The issue (I think anyway) is specific to configuration in bridge.json and I don't see any way on Deck.net to change these things, so I don't have a link for you there. Sorry. I will paste the code below though
The problem:
When the project is compiled as a `UMD` or `CommonJS` module, dictionary methods are throwing Javascript errors. Here's some code that should reproduce the problem:
using System.Collections.Generic;
namespace Foo.Bar {
public class Foo {
public struct CustomObject
{
public readonly string Str;
public CustomObject (string str)
{
this.Str = str;
}
}
public static readonly IReadOnlyDictionary<int, CustomObject> Dict = new Dictionary<int, CustomObject> (new Dictionary<int, CustomObject> {
{ 1, new CustomObject ("yolo") }
});
}
public class Bar {
public void FooBar() {
Foo.Dict.TryGetValue(1, out var customObject);
}
}
}
and the bridge.json module declaration is just: "module": {
"name": "FooBar",
"type": "UMD"
}
When you call (in Javascript)(new Bar()).FooBar()
an error is thrown:FooBar.Foo.Bar.Foo.Dict.System$Collections$Generic$IReadOnlyDictionary$2$System$Int32$FooBar$Foo$Bar$Foo$CustomObject$tryGetValue is not a function
When I debug the Javascript I see that the function exists on the object, but the property name for the function has the $FooBar portion omitted. Removing that portion of the name from the compiled Bar.FooBar source in a text editor and saving it enables the script to run without error.
Comment