This project has moved and is read-only. For the latest updates, please go here.

options starting with numbers convert to enums starting with underscores which generates warnings about not being CLS-compliant

Sep 12, 2015 at 6:39 PM
Edited Sep 12, 2015 at 6:51 PM
Options in Option Sets such as "01 - Ontario" are converted to enums such as "_01Ontario". This produces a warning that the name is not CLS-Compliant. The explanation is covered on Stack Overflow. TLDR; public properties cannot begin with underscores to support .NET languages that don't support underscores. A simple solution can be to decorate the property with the following attribute as suggested by Martin Brown's answer
Sep 12, 2015 at 6:48 PM
Edited Sep 12, 2015 at 6:52 PM
Note that the properties of entity classes that return the non-CLSCompliant enums also need the [CLSCompliant(false)] attribute, so both OptionSets.cs and Entities.cs are affected.
Sep 16, 2015 at 4:42 AM
So apparently you've defined that your assembly is CLSCompliant and that must be important to you for some reason. Would it make more sense to allow you to specify the prefix, so rather than an Underscore you could make it "o_01Ontairo"? I'm thinking this would probably be easier to implement.
Sep 23, 2015 at 3:34 PM
Edited Sep 23, 2015 at 3:34 PM
Good point. I don't need my assembly to be CLSCompliant. I made my DLL project by using the Project Template named "Dynamics CRM 2013 Plug-in Library" from the Developer Toolkit which includes the [assembly: CLSCompliant(true)] attribute in the AssemblyInfo.cs class. So I can just remove that attribute and I would be fine, but your suggestion to add a prefix would be nice for those that need CLSCompliant assemblies.