Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I understand correctly: What you are looking for is a tool that controls the compilation by your attributes. You may check if stylecop or fxcop fit your needs. Alternatively you might extend Visual Studio to access the source code model. An extension may check the source code (see <a href="http://blogs.msdn.com/b/sqlserverstorageengine/archive/2007/03/02/using-visual-studio-s-code-model-objects-for-code-base-understanding.aspx" rel="nofollow">http://blogs.msdn.com/b/sqlserverstorageengine/archive/2007/03/02/using-visual-studio-s-code-model-objects-for-code-base-understanding.aspx</a>), evaluates the attributes and generate compiler warnings, errors whatever you like.</p> <p>===================================</p> <h1>Original Answer:</h1> <p>Answer: You just have to provide the corresponding constructor</p> <pre><code>[AttributeUsage(AttributeTargets.All)] public class HelpAttribute : System.Attribute { // Required parameter public HelpAttribute(string url) { this.Url = url; } // Optional parameter public string Topic { get; set; } public readonly string Url; } public class Whatever { [Help("http://www.stackoverflow.com")] public int ID { get; set; } [Help("http://www.stackoverflow.com", Topic="MyTopic")] public int Wew { get; set; } // [Help] // without parameters does not compile public int Wow { get; set; } } </code></pre> <p>The allowed parameter types are liste at MSDN: <a href="http://msdn.microsoft.com/en-us/library/aa664615(v=vs.71).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/aa664615(v=vs.71).aspx</a></p> <p>Further reading: <a href="http://msdn.microsoft.com/en-us/library/aa288454(v=vs.71).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/aa288454(v=vs.71).aspx</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload