Generate Property Internal set

Asked

Viewed 84 times

2

Because from the version of Visual Studio 2015 every time I have an attribute generated in a class the same is generated with the set internal? In previous versions VS generated as public.

  • This happens when you use the shortcut prop?

  • when I use the Ctrl+.

  • Good luck: http://stackoverflow.com/q/32232135/221800 :)

  • From what I understand there, it would be that for some developers it is interesting that it manages as internal?

  • I believe this is so because you created the property using the CTRL + within the same project, so for privacy reasons of defining the property the VS places as Internal. I think that creating in another project should come as public. It should be possible to modify this behavior by changing some template from VS, but I’m not sure.

  • Yes, I remember that in 2013 he generated the classes without the public, then I edited a template to always add the public, only to generate the property I did not find which template I have to change.

Show 1 more comment

1 answer

0

It depends on where you want to create this property, and also on the nomenclature format.

public class Teste
{
    public Teste()
    {
        minhaProriedade = 1; // private readonly 
        OutraPropriedade = true; // public
    }

    public Metodo()
    {
        MaisUmaProp = "OK"; // como private, internal ou protected, se tiver herança
    }
}

And so it goes, depending on where the creation of the property will come from, Visual Studio will try to guess the level of security of the property.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.