简体   繁体   English

如何防止生成的接口实现使用类型别名?

[英]How can I prevent the generated implementation of an interface from using a type alias?

I'm currently using Visual Studio (specifically, 2012 Express). 我目前正在使用Visual Studio(特别是2012 Express)。 I have an interface already defined as follows: 我有一个接口已经定义如下:

interface IMyInterface
{
    public String Data { get; set; }
}

If I have an empty class: 如果我有一个空类:

class MyClass : IMyInterface
{
}

And I right-click on the IMyInterface , I can select "Implement Interface". 我右键单击IMyInterface ,我可以选择“实现接口”。 When I do this, the auto-generated code produces the following: 当我这样做时,自动生成的代码产生以下内容:

class MyClass : IMyInterface
{
    public string Data
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }
}

My question is, is there a way that I could have the following auto-generated: 我的问题是,有没有办法可以自动生成以下内容:

    public String Data

Instead of: 代替:

    public string Data

?

There is no way to do this. 没有办法做到这一点。 It's hard-coded to use the builtin aliases where possible. 在可能的情况下使用内置别名是硬编码的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我可以使用另一个接口实现从接口转换为具体类型 - Can I cast from an interface to a concrete type with another interface implementation 如何防止在生成的类型参数表达式中转换是接口 - How to prevent Convert in generated expression for type parameter is interface 如何将接口的具体实现传递到接受通用类型接口的MVC局部视图中? - How can I pass a concrete implementation of an interface into a MVC Partial View that accepts an Interface of generic type? 如何防止生成验证属性? - How can I prevent a validation attribute from being generated? 如何将表达式从类型接口转换为特定类型 - How can I cast an expression from type interface, to an specific type 我如何别名实体框架代码首先从数据库生成的部分类? - How can I alias partial classes generated by Entity Framework Code First From Database? 为什么不能将强制转换接口键入其具体实现? - Why can I not type cast Interface into its concrete implementation? 我如何获得通用接口的接口实现 - how can i get the interface implementation of a generic interface 如何将接口的实现作为返回类型返回? - How to return an implementation of an interface with interface as return type? 如何使用显式类实现接口类型 - How can I implement an interface type using a explicit class
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM