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 回答