Skip to main content
Code Review

Return to Answer

deleted 19 characters in body
Source Link
user73941
user73941

There are not much to say other than the usual missing argument null check:

It is valid to write the following:

 string test = null;
 test.RemoveDuplicateChars();

and RemoveDuplicateChars will be called with a null for the this argument text. Therefore you'll have to test for null:

public static string RemoveDuplicateChars(
 this string text, Func<string, string> normalizer = null)
{
 if (string.IsNullOrWhiteSpace(text) == null)
 return text;
 ...

or throw an exception...


The default initialization of normalizer could be a little less verbose:

 normalizer = normalizer ?? ((x) => x.Normalize());

A minor detail: Angstrom and Å: is also represented by \u00C5, which your code interprets as equal to Angstrom, but MS Word interprets them as different when using its Find-function?

There are not much to say other than the usual missing argument null check:

It is valid to write the following:

 string test = null;
 test.RemoveDuplicateChars();

and RemoveDuplicateChars will be called with a null for the this argument text. Therefore you'll have to test for null:

public static string RemoveDuplicateChars(
 this string text, Func<string, string> normalizer = null)
{
 if (string.IsNullOrWhiteSpace(text))
 return text;
 ...

or throw an exception...


The default initialization of normalizer could be a little less verbose:

 normalizer = normalizer ?? ((x) => x.Normalize());

A minor detail: Angstrom and Å: is also represented by \u00C5, which your code interprets as equal to Angstrom, but MS Word interprets them as different when using its Find-function?

There are not much to say other than the usual missing argument null check:

It is valid to write the following:

 string test = null;
 test.RemoveDuplicateChars();

and RemoveDuplicateChars will be called with a null for the this argument text. Therefore you'll have to test for null:

public static string RemoveDuplicateChars(
 this string text, Func<string, string> normalizer = null)
{
 if (text == null)
 return text;
 ...

or throw an exception...


The default initialization of normalizer could be a little less verbose:

 normalizer = normalizer ?? ((x) => x.Normalize());

A minor detail: Angstrom and Å: is also represented by \u00C5, which your code interprets as equal to Angstrom, but MS Word interprets them as different when using its Find-function?

Source Link
user73941
user73941

There are not much to say other than the usual missing argument null check:

It is valid to write the following:

 string test = null;
 test.RemoveDuplicateChars();

and RemoveDuplicateChars will be called with a null for the this argument text. Therefore you'll have to test for null:

public static string RemoveDuplicateChars(
 this string text, Func<string, string> normalizer = null)
{
 if (string.IsNullOrWhiteSpace(text))
 return text;
 ...

or throw an exception...


The default initialization of normalizer could be a little less verbose:

 normalizer = normalizer ?? ((x) => x.Normalize());

A minor detail: Angstrom and Å: is also represented by \u00C5, which your code interprets as equal to Angstrom, but MS Word interprets them as different when using its Find-function?

lang-cs

AltStyle によって変換されたページ (->オリジナル) /