在代码上生成方法存根太多{

Def*_*ult 0 c# visual-studio-2008

我刚才注意到,当你尝试生成的代码的方法存根那里有更多的{},该方法存根被错误地生成.

例如:

    static void Main(string[] args) {
        myMethod();
    }
Run Code Online (Sandbox Code Playgroud)

创建方法存根以便myMethod()正确扩展为:

    static void Main(string[] args) {
        myMethod();
    }

    private static void myMethod() {
        throw new NotImplementedException();
    }
Run Code Online (Sandbox Code Playgroud)

然而!如果我现在继续并添加:

{
    newMethod();
Run Code Online (Sandbox Code Playgroud)

并尝试生成方法存根newMethod(),我得到这个:

        static void Main(string[] args) {
            myMethod();
            {
                newMethod();
        }

        private

private static void newMethod()
{
    throw new NotImplementedException();
} static void myMethod() {
            throw new NotImplementedException();
        }
    }
Run Code Online (Sandbox Code Playgroud)

我可以以某种方式配置Visual Studio以正确执行吗?或者这是否需要向某人报告?

Dav*_*wns 6

I think this is a case of garbage in, garbage out.

If your code is written in such a way that it's impossible for the auto-generation tools to tell where one code block ends and another begins then I wouldn't expect it to be able to produce meaningful results.