Eric points out some of the new syntax changes we’ve made in C# 2.0 for FCLC compliance.  These changes could break some of your existing code so you should make sure to verify 1.1 code when moving to VS 2005 (Whidbey).

 

You should also be aware of the new BCL changes that will help developers write decent and non-offensive code, including changes to System.String and a new exception class. 

 

System.String

To check whether a string contains indecent content, developers can now call the IsIndecent method which returns true or false if the string is indecent.  Below is the copy/paste from ObjectBrowser on one of our latest VS builds (40326) 

public static bool IsIndecent(string str)

    Member of System.String

 

Summary:

Determines whether a specified System.String object is indecent. 

 

Parameters:

str: A System.String.

 

Return Values:                                       

 true if the value of str is indecent, otherwise, false.  

 

Example:

if (String.IsIndecent(text))

{

//Do something here             

}  

 

We have also added the ability to estimate the cost of an FCLC fine based on the contents of a string using a new method, EstimateFine.

public static float EstimateFine(string str)

    Member of System.String

 

Summary:

Provides an estimate of an indecency fine based on string contents using floating-point precision. 

 

Parameters:

str: A System.String.

 

Return Values:                                       

Single-precision floating point estimate of FCLC fines. 

 

Example:

float f = String.EstimateFine(text);

 

Note – We’ve also added a culture specific overload to EstimateFine which enables you to estimate indecency fines in other cultures.  Currently this returns 0.0 except when the culture is set to ‘EN-US’.

public static float EstimateFine(string str, System.Globalization.CultureInfo culture)

 

We’ve also changed the behavior of strings so that a string marked with a public accessor (ex: public string s;) that contains indecent content will now raise a System.IndecentException as outlined below:

 

System.IndecentException

public class IndecentException : System.Exception

    Member of System

 

Summary:

The exception that is thrown when the content of a string with a public access modifier is indecent. 

 

 

Other keywords

We are still debating this, so any feedback is appreciated.  Are any of the following language constructs, classes, properties, or methods listed below considered offensive or indecent?

  • unsafe
  • using
  • sizeof
  • EntryPointNotFoundException
  • MakeDirty() (System.Windows.Forms.AxHost)
  • SetDirtyObject (System.Web.UI.StateManagedCollection)
  • IsDirty() (System.Runtime.InteropServices)

Your feedback, as always, is appreciated.