Reputation: 43
We have some code which uses attributes with long string Parameters (descriptions and the like) - it would be great, if we could hide attributes or at least its Parameters.
Is it possible to hide/collapse attributes (in C# code) in Visual Studio 2015
Upvotes: 2
Views: 1031
Reputation: 3896
You can declare your parameter as a private constant:
private const string LongTextParam = "Some very long text ...";
...
[MyAttribute(LongTextParam)]
public int SomeProperty { get; set; }
#region can help you:
#region MyAttribute
[MyAttribute("A very long string parameter .... ")]
#endregion
public int SomeProperty { get; set; }
Editor in Visual Studio can collapse such regions.
Also you can combine both approaches - move param text into private field / constant and wrap it with region.
Upvotes: 3
Reputation: 75
As other have pointed out, this can't be done currently on VS.
The suggested solution of using regions will probably work although I would advise against it.
I can see how attributes can be obstrusive if you have many, or just a few but they have many, or long, parameters, but they might be an essential part of your code and without seeing it you might miss something fundamental.
My 2 cents.
Upvotes: 1
Reputation: 78
I think it's not possible, but you can use regions
#region SomeShortDescription
[MyAttribute("Long description here...")]
#endregion
For more information: https://msdn.microsoft.com/en-us/library/9a1ybwek.aspx
Upvotes: 1