ruccho/UniTyped

別アセンブリで定義されたUniTyped付きの型にアクセスできない点

Opened this issue · 2 comments

いつも便利に使わせて頂いております。
本ライブラリに関してアセンブリを切り分けた際に発生する不具合を見つけたので再現方法を記載させて頂きます。

環境

  • Unity 2022.2.17f1

再現方法

1. アセンブリAでUniTyped属性付きのSampleModelクラスを定義します

using System;
using UniTyped;

namespace A
{
    [UniTyped]
    [Serializable]
    public class SampleModel
    {
    }
}

2. アセンブリBでSampleModel型のシリアライズ可能なフィールドを持ったHogeクラスをUniTyped属性付きで定義します

using System;
using A;
using UniTyped;

namespace B
{
    [UniTyped]
    [Serializable]
    public class Hoge
    {
        public SampleModel SampleModel;
    }
}

3. アセンブリB側で生成されたHogeView構造体をインスタンス化し、SampleModelプロパティにアクセスするコードを記述します

using System;
using A;
using UniTyped;
using UniTyped.Generated.B;

namespace B
{
    [UniTyped]
    [Serializable]
    public class Hoge
    {
        public SampleModel SampleModel;

        private static void Start()
        {
            HogeView view = new();
            var temp = view.SampleModel;
        }
    }
}

4. Unity Editor上に戻るとコンパイルが走り、コンパイルエラーとなります。その際のエラーメッセージは以下のとおりです。

Assets/B/Hoge.cs(17,29): error CS1061: 'HogeView' does not contain a definition for 'SampleModel' and no accessible extension method 'SampleModel' accepting a first argument of type 'HogeView' could be found (are you missing a using directive or an assembly reference?)
ruccho commented

ご報告ありがとうございます!
こちらですが、 b264598 で修正されたと思います。

修正確認できました!ご対応頂きありがとうございます!