0

I am working on a tool that uses the Microsoft.Build namespaces, to programmatically build a C# project, among other things. The projects can be created via Visual Studio or generated using parameter substitution of code template.

I need to validate that the given project is a valid one. I came across this question that has rules for a valid project name, but I believe the list is incomplete.

For example - as per the C# CLS - an identifier cannot be used in a project name, unless it is prefixed with @. Referred here. Another example is, if the input project name is a number, then Visual Studio prefixes it with an underscore.

So, question is - is there a namespace/api/fancy regular expression that I can use to create a new C# project programmatically, outside of Visual Studio, that will apply all such rules that the C# CLS specifies?

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
Srikanth Venugopalan
  • 9,011
  • 3
  • 36
  • 76
  • Your question should be in the format: "I am looking for a regex that matches these rules [list rules], this is what I have so far [show current efforts]". As it stands, you are basically asking us to go and search for the rules for you – musefan Dec 15 '14 at 12:23
  • @musefan - I believe I listed some rules that are not consistent(at least to me). I even refered to the MSDN doc that I have been referring for a rule. I am not looking for the rules - I am rather looking at a (possible) API similar to `Microsoft.Build` that could do this for me. Am happy to take an answer that says it does not exist! – Srikanth Venugopalan Dec 15 '14 at 12:25
  • Asking for an API is also considered "off-topic". I suggest you just go with the rules you know/find and leave it at that. What's the worst that can happen if you miss a rule? – musefan Dec 15 '14 at 13:07

0 Answers0