0

私はC#で(ImportLibraryとして)このコードを持っています:

[IgnoreNamespace]
[Imported]
public class MyClass
{
    public object Value
    {
        get { return null; }
        set { }
    }
}

そして、次のようにクラスを消費します。

myClass.Value = 0;
obj val = myClass.Value;

すべてが問題なくコンパイルされます-それで問題ありません:)しかし、結果は次のようになります。

myClass.set_value(0);
var val = myClass.get_value();

私が本当に欲しかったのは:

myClass.setValue(0);
var val = myClass.getValue();

したがって、アンダースコア (_) と大文字は使用できません。どうすればこれを制御できますか? [ScriptName("Value")] を試してみましたが、うまくいきませんでした。

4

1 に答える 1

0

Right now there isn't support for that pattern of properties. You'd simply have to have methods - GetValue and SetValue.

Its changeable of course, but I fear creating endless set of permutations for all the possible different patterns when looking at script generation overall, rather than just property syntax. I actually am not attached to "get_" ... it was simply to separate what is the actual name vs. what was tacked on, as well as to use the same pascal-case to camel-case routine already in place ... so open to the idea of switching to just "get" but it would need to apply to "add_" and "remove_" as well for events. Why don't you open an issue on the script# github repo (https://github.com/nikhilk/scriptsharp), and see if there is concensus for changing?

So to understand the motivation, is it because you're trying to generate script that something else existing is calling and hence must be called "getValue"... or is this stemming from preference.

于 2012-09-21T17:07:33.213 に答える