Changes to C# and .NET Framework
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.
Comments
- Anonymous
April 01, 2004
Wouldn't EstimateFine for EN-US just be:
float EstimateFine(string str)
{
if (IsIndecent(str))
return 500000.0;
else
return 0.0;
}
Guess it can't be hard coded though (unless there's a constitutional amendment), so this better activate a web service instead, maybe us.gov can host? - Anonymous
April 01, 2004
Nice one Dan! You almost had me there. Then I remembered the date. - Anonymous
April 01, 2004
Why is this a part of the string class? Isn't the string class heavy enough as it is? What's the point of namespaces if they aren't going to be used properly?
It should be something like...
Microsoft.Utils.ContentFilter.IsDecent or something like that.
/me groans - Anonymous
April 01, 2004
Well from what I see, a TrimIndecent or equivalent method is absolutely required.
I would also recommed naming the exception IndecencyException; it is a good exception and should not have negative name.
I hope that there are compile time checks so we don't have to wait until runtime IndecencyExceptions are thrown for readonly and const strings.
It is important not to overlook enums, as they are often exposed to end users.
Also numbers, what about 666? - Anonymous
April 01, 2004
The comment has been removed - Anonymous
April 01, 2004
nice one Dan! LOL! - Anonymous
April 01, 2004
If you're going to have an IsDirty() method, you need to also use the System.Jackson.Michael namespace.
Also, it's Bubba has two b's... not sure how that compiled. :P - Anonymous
April 01, 2004
public boolean IsIndecent()
{
return IndexOf("java") != -1;
} - Anonymous
April 01, 2004
rofl! Great one! :) - Anonymous
April 01, 2004
using System.Fool; - Anonymous
April 01, 2004
Robert Scoble - Anonymous
April 02, 2004
I noticed that Eric took down his post :-) - Anonymous
April 02, 2004
Microsoft Developer Dan Fernandez reports on the future of the C# language: 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. Source: iBLOGthere4iM... - Anonymous
July 18, 2004
The comment has been removed