Should you use XML comments on field variables, properties & constructors? [closed] - c#

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
So far I understand that its good practice to XML comment a classes methods but is there a standard for how much you should use XML comments?
Should I be using them to document field variables, properties & constructors or is that just overkill?
Had a look about the web but can't see any hard and fast rules for this sort of thing.

There are two reason to use XML comments opposed to plain English:
If the comments follow the correct format they will show up in IntelliSense, meaning when I use your class I can see that int a is supposed to be the count or whatever the same way I see helpful info when I'm using .NET methods,
If you use the XML formats Microsoft supports you can create html (or other formats of) documentation using SandCastle or similar third party utilities.
So, if you're taking the time to write comments, you may as well make them the XML ones that VS encourages.

Related

Is there a good solution for a C# html sanitizer? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
A user can enter HTML that will later be displayed to other users. The WYSIWYG plugin i'm using sanitizes the HTML from the front end. It removes all potentially malicious tags (script, src, anything starting with "on" etc) I obviously need to do some validation in the back end as well.
Does anyone know of a good solution for C#? I keep seeing this http://roberto.open-lab.com/2010/03/04/a-html-sanitizer-for-c/, though I'm a little hesitant to use some code from a random blog. Are there any well known plugins? What do most people do in this situation?
You can use HtmlAgilityPack, which is a well maintained library for all things related to HTML tags. A best practice would be to implement a White List, which is a list of allowable tags. This SO question might be exactly what you need:
HTML Agility Pack strip tags NOT IN whitelist

Were method cascades ever considered for C#? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Smalltalk supports a syntax feature called "message cascades". Cascades are being adopted by the Dart Programming language.
As far as I know, C# doesn't support this. Were they ever considered during the design of the language? Is it conceivable that they could appear in a future version of the language?
In VB.Net there is the with keyword which I believe is used for this purpose (correct me if I'm wrong on this), however in C# they decided that it can often hurt readability and left it out (good in my opinion).
Some short details can be found at the below link, however the link to the microsoft page is no longer working:
http://blogs.msdn.com/b/csharpfaq/archive/2004/03/11/why-doesn-t-c-have-vb-net-s-with-operator.aspx
Note: If anyone has the following link archived I would love to read it (as the link is not working):
http://msdn.microsoft.com/vcsharp/team/language/ask/withstatement/default.aspx

DataContractSerializer Best Practices? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
Edit -- I'll try to make my question more to the point
I am working with the DataContractSerializer. I noticed that when I instance the serializer, I can specify the Namespace and the Name. Is there any guidance out there (or maybe a best-practice) to describe when I might want to take control of the name and namespace, and what I might want to use for the values?
I was tempted to use the namespace and class name of the class that I am serializing deserializing. Is that a good or bad practice?
DataContractSerialializer is a contract-based serializer, so forwards compatibility shouldn't a huge problem as long as you are adding - and if you do want to rename, you can hide that by adding the old name via attributes. As such, I would say "keep it simple" - trying to get clever is the cause of many bugs.
Re "What do you think?" (comments) - I think I'd rather use protobuf-net, but I'm somewhat biased :p

Are C#'s attributes better designed than Java's annotations? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
After reading this old post from Clinton Begin (creator of iBatis) I really wonder if his claims about annotations vs. attributes are widely accepted or if there is disagreement about it.
His points are:
Annotations are not extendable
No support for positional arguments
Java-unlike definition syntax
annotation is not a keyword (unlike enum)
Do those claims have merit and how does C# improve on that?
Well taken one by one those points obviously have merit:
Attributes are classes you can extend and query as you wish. You can even add your own!
Position arguments (I'm guessing you mean named arguments) are indeed possible with C#, with full Intellisense support.
Can't really comment on how weird it looks, although coming from Razor it makes me think of macro expansion.
Attributes don't have a keyword either, they're just a normal class.
That doesn't make Java's implementation worse, since they had a different goal in mind: backwards compatibility. C# had the advantage of building the language from scratch (and then progressing forward instead of maintaining strict backwards compatibility).
As a nit-pick though, nothing you or I mentioned are part of C#, they are part of the .NET runtime and can be found equally well in VB.NET and F#.

How to generate Automatically resx files for project [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I want to generation automatically Resx files for my project, I've heared that there's program which does it.
Can anyone tell me it's name?
The only program I know is Visual Studio. You can easily create your own program by using the ResXResourceWriter class.
As Hans stated, for components such as forms and user controls, you can do this via the "Localizable" property. For other ".resx" files, you can easily create your own localized ".resx" file but it needs to be properly named (you can read up on this - Google for "satellite assemblies" for starters). If your goal is dealing with translations in general however, then unless your app is very small, this approach is difficult, tedious and error-prone (trying to track changed strings on your own for instance, whose existing translations have become obsolete). There are 3rd-party packages that can help you however, and I'm the author of one of them (in the interest of full disclosure). See http://www.hexadigm.com.

Categories

Resources