Skip to content

Does not work in Unity due to 'init' keyword in properties #113

Open
@Monsoonexe

Description

@Monsoonexe

Describe the bug

The readme claims that this repo can be used in Unity (the game engine, I'm assuming). However, this is not the case (tested in 2020.3). This repo uses the 'init' keyword for properties, which are explicitly not a feature supported by unity: source

Steps to reproduce the bug

Download source. Go through each folder of the 'lib' folder and copy-paste .dll into /Plugins folder in Unity. It'll compile. Now in your code, try to use any property that uses the 'init' keyword (in my case, none of the properties on DeviceData are supported. If you try to access these properties in your code, when you recompile in Unity, you'll get an error in the console about "property... is not supported by the language...". Even picking .dll from .net framework 3.5 or 4.5 has same issues.

A work-around I use is to re-write the properties as extension methods and use Reflection to call the underlying get_Name auto-property functions.

Unity 2020.3 (but the Unity 6 doc suggest this feature is still unsupported). Using Mono scripting backend 4.x.

Expected behavior

I expected the claims to be correct -- all features are supported. If some features aren't supported, please notate as such.

Screenshots

image
image

NuGet package version

Latest Source

.NET Platform

Others

Platform type

Windows

System version

No response

IDE

Visual Studio 2022

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions