Unable to create a function with parameter when Type.IsValueType is true
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 35/100
調査の方向性
src/Value.cs の Value.TryGetKind から始め、次に例外が報告される src/Function.cs の GetFunctionType と Function.FromCallback の周辺を調べてください。Vector3 と object のパラメーターを使用して Unity 2021.3 の externref サンプルを再現し、サポートされている動作とテストが UnityEngine.Vector3 のような値型を対象としているか確認してください。
索引モデルが issue の本文から書いたものです。
説明
I have a really simple adaption of the externref sample, running inside unity 2021.3, whose csharp runtime is ostensibly .NET standard 2.1 compatible:
(module
(import "" "getX" (func $.getX (param externref) (result f32)))
(func (export "run") (param externref) (result f32)
local.get 0
call $.getX
)
)
public class WasmTest : MonoBehaviour
{
public TextAsset watSource;
void Start()
{
var engine = new Engine();
var module = Module.FromText(
engine,
watSource.name,
watSource.text
);
var linker = new Linker(engine);
var store = new Store(engine);
linker.Define(
"",
"getX",
Function.FromCallback(store, (Vector3 vec) => ((Vector3)vec).x)
);
var instance = linker.Instantiate(store, module);
var run = instance.GetFunction<object, float>("run");
float res = run(transform.position);
Debug.Log($"the x is {res}");
}
}
However, as written, I get
WasmtimeException: Unable to create a function with parameter of type 'UnityEngine.Vector3'.
Wasmtime.Function.GetFunctionType (System.Type type, System.Boolean hasReturn, System.Collections.Generic.List`1[T] parameters, System.Collections.Generic.List`1[T] results, System.Boolean& hasCaller, System.Boolean& returnsTuple) (at C:/Users/s/source/repos/wasmtime-dotnet/src/Function.cs:2411)
Wasmtime.Function..ctor (Wasmtime.IStore store, System.Delegate callback, System.Boolean hasReturn) (at C:/Users/s/source/repos/wasmtime-dotnet/src/Function.cs:2242)
Wasmtime.Function.FromCallback[T,TResult] (Wasmtime.IStore store, System.Func`2[T,TResult] callback) (at C:/Users/s/source/repos/wasmtime-dotnet/src/Function.cs:300)
WasmTest.Start () (at Assets/wasmtest/WasmTest.cs:25)
If I change the function argument type from Vector3 to just object and do the cast manually, it works as expected. Looks like it's because it falls out of Value.TryGetKind at https://github.com/bytecodealliance/wasmtime-dotnet/blob/387edd242f105d5394399acd19c25509ebb42b02/src/Value.cs#L210 , because unity sets Type.IsValueType == true.
Is that test of IsValueType necessary? I don't know if this is just a weird unity environment thing.
- 主要言語
- C#
- スター
- 524
- フォーク
- 71
- 平均マージ
- 17時間 26分
- マージ済み PR(30日)
- 6
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
bytecodealliance/wasmtime-dotnet のほかの issue
-
難易度 5/5 1週間以上 初心者へのやさしさ 42/100
bytecodealliance/wasmtime-dotnet#374 · コメント 2 件 ·
-
wasip3 supportオープン
難易度 5/5 1週間以上 初心者へのやさしさ 32/100
bytecodealliance/wasmtime-dotnet#350 · コメント 9 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
-
WasmGCオープン
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
bytecodealliance/wasmtime-dotnet#342 · コメント 8 件 ·
bytecodealliance/wasmtime-dotnet の issue をすべて見る
似ている issue
-
area-ai bug untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
dotnet/extensions#7893 ·
メンテナーはふだん 1 日以内に返信
-
devtools documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
area-System.ComponentModel untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
dotnet/runtime#136608 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
fix: Cannot reopen dialog after closing with escape key in FluentDialog対応中かも @bryan-ramirez が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
microsoft/fluentui-blazor#5572 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
sillsdev/languageforge-lexbox#2846 ·
メンテナーはふだん 1 日以内に返信