This new feature is really convenient.
Lately I read the document of the “Microsoft All-In-One Code Framework”, and it mentions that “Optional Parameters” is not CLS-Compliant.
So I tested it by using “Optional Parameters” in a public API, and turned on FxCop, then I compiled and FxCop did not complain about anything. At the mean while, FxCop did report a warning when I add an API that has uint as its return type.
So now I am confused, is “Optional Parameters” CLS-Compliant or not?
And what’s the best way to find out whether a new language feature is CLS-Compliant or not?
Optional arguments are “sort-of” CLS-compliant. Methods with optional arguments are legal and can be successfully compiled with the
CLSCompliantattribute, but callers of those methods don’t necessarily need to take account of the default parameter values or the optional attribute. (In which case those methods would behave in exactly the same way as standard methods, requiring that all the arguments be stated explicitly at the call site.)(Taken from the documentation for “CA1026: Default parameters should not be used”.)