Is there any way to make F# discriminated unions work in Unity? - unity3d

I am experimenting with F# in Unity. I use compiled F# library and FSharp.Core.dll copied to Assets in Unity. Simple scripts work but when I add discriminated union type like
type A =
| AInt of int
| AString of string
then I get this error in Unity: "Unable to load attribute info on method fs.A:.ctor (). Are you missing a reference?".
What can be wrong and is there a way to make it work?

Ensure you are using F# 4.1 - 4.8 in order to be compatible with Unity. F# 5 and 6 are incompatible in exactly the same way as a C# project targeting beyond .NET Standard 2.1.
Tell me more
.NET profile support
https://en.wikipedia.org/wiki/F_Sharp_(programming_language)
.NET Standard Versions

Related

How to import a class module (.psm1) in PowerShell 4 (doesn't recognize Using statement)?

I have a class module and I'm forced to use PowerShell 4. It doesn't recognize the "using" keyword as it was introduced in PS5.
Is there a way around this?
Is there a way around this?
No!
Classes (and the using ... directives) were introduced in Windows PowerShell 5.0 - the parser in previous versions wouldn't know what to do with either keyword.
If you want to retain backwards compatibility with 4.0 you need to remove all type definitions and using statements from the module code and leverage either pre-compiled binaries or define your custom types with Add-Type at runtime instead.

Where is FloatField?

I've added Lucene.Net to a .Net 6 Core project and indexing docs with TextField, StringFiled, and Int32Field all work fine but FloatField doesn't seem to be supported. I'm using LuceneVersion.LUCENE_48. According to https://lucene.apache.org/core/4_1_0/core/org/apache/lucene/document/FloatField.html, FloatField has been available since version 4.1 of Java Lucene. What am I missing? Thanks
See the Lucene.NET 4.8.0 migration guide. Numeric types and method names including numeric types have been changed to use .NET conventions.
Instead of Float use Single. Note that Lucene.Net.Queries.Function.ValueSources.SingleFunction was renamed Lucene.Net.Queries.Function.ValueSources.SingularFunction to distinguish it from the System.Single data type.
So, FloatField has been renamed to SingleField.

How to get swift mangled object name

I've learned that swift actually creates a naming method called "mangling" used internally for all objects.
All threads talk about demangling, but how to actually get the mangled name?
i've tried
1- object_getClass(self)
2- NSStringFromClass(MyClass.self)
but they return the normal class name.
I've found this demangle project..
https://github.com/mattgallagher/CwlDemangle/blob/master/CwlDemangle/CwlDemangle.swift
is there a mangling project maybe?
Note: Im using swift 3.0.1
xcode ships with a command line tool to de-mangle names.
Type in:
swift demangle
Then find your mangled class name..
__TMaC17find_the_treasure15YD_Secret_Class
Then watch it spit out the name..
find_the_treasure.YD_Secret_Class
If you want to observe the mangled names, as you asked, you can put the produced Swift iOS or macOS binary into a dissassembler like Hopper, iDAPro or radare2.
The tools to automatically de-mangle names are already here (refer to Hopper v4.0 Dissassembler).

EntityCommandExecutionException with EF 6 in project net 4.0?

I have using entity framework 6 in a project that is net 4.0, and when I instaled the nuget package, the project adds the reference to EntityFramework.dll and EntityFrameWork.SqlServer.dll.
However, I want to capture the exception EntityCommandExecutionException, but there is not avaliable in neither of the both dlls.
I know that I can add a reference to System.Data.Entity, but I don't konw if this a good solution, because when I try to use the enum EntityState there are a conflict because the are one in the System.Data.Entity and other in EntityFramework.dll.
So the quiestion is if it is a good idea to use the System.Data.Entity library with EF 6. And if it is a bad idea, which is the equivalent exception of EntityCommandExecutionException in EF 6?
Thanks.
EF6 does not use System.Data.Entity.dll so adding a reference to this assembly won't help since EF6 will throw its own EntityCommandExecutionException. Actually adding a reference to an EF6 project will create even more confusion since the two are not designed to work together even though the type names tend to be called the same (EF6 was build by merging System.Data.Entity.dll and EntityFramework.dll code bases but is not binary compatible with EF5). In your app you need add
using System.Data.Entity.Core;
since this is where the EntityCommandExecutionException type lives in EF6.

Dynamic resultset with dapper on 3.5

I've got a store procedure call returning a recordset whith field unknown in advance. For some interop reason I need to make it working on 3.5, so I don't have any dynamic support.
Is there some built-in solution in dapper? I did not find any by myself.
If there is no such a solution, does it make sense ( and does it work ) to create on the fly a type exposing the property I would fetch ?
EDIT
I managed to add a completely external solution ( without tweaking the original codebase ) by creating a dynamic object in c# 3.0.
Here is the extension dapper code
and here the factory for the dynamic object.
Well, actually the dynamic support in dapper is implemented via ExpandoObject, which is basically just a dictionary. It would be pretty simple to tweak the existing code to return IDictionary<string,object> instead of dynamic in the case of 3.5