src/Shared/EntityFramework/Migrations/Design/VisualBasicMigrationCodeGenerator.cs
/// <summary>
/// Removes any invalid characters from the name of an database artifact.
/// </summary>
/// <param name="name"> The name to be scrubbed. </param>
/// <returns> The scrubbed name. </returns>
Removes any invalid characters from the name of an database artifact.
Removes any invalid characters from the name of an database artifact .
[SuppressMessage("Microsoft.Security", "CA2141:TransparentMethodsMustNotSatisfyLinkDemandsFxCopRule")]
        protected virtual string ScrubName(string name)
        {
            Check.NotEmpty(name, "name");
            var invalidChars
                = new Regex(@"[^\p{Ll}\p{Lu}\p{Lt}\p{Lo}\p{Nd}\p{Nl}\p{Mn}\p{Mc}\p{Cf}\p{Pc}\p{Lm}]");
            name = invalidChars.Replace(name, string.Empty);
#if NETSTANDARD
            {
                if ((!char.IsLetter(name[0]) && name[0] != '_')
                    || IsVbKeyword(name))
                {
                    name = "_" + name;
                }
            }
#else
            using (var codeProvider = new VBCodeProvider())
            {
                if ((!char.IsLetter(name[0]) && name[0] != '_')
                    || !codeProvider.IsValidIdentifier(name))
                {
                    name = "_" + name;
                }
            }
#endif
            return name;
        }
[ SuppressMessage ( " " , " " ) ] protected virtual string ScrubName ( string name ) { Check . NotEmpty ( name , " " ) ; var invalidChars = new Regex ( @"[^\p{Ll}\p{Lu}\p{Lt}\p{Lo}\p{Nd}\p{Nl}\p{Mn}\p{Mc}\p{Cf}\p{Pc}\p{Lm}]" ) ; name = invalidChars . Replace ( name , string . Empty ) ; if NETSTANDARD { if ( ( ! char . IsLetter ( name [ 0 ] ) && name [ 0 ] != ' ' ) || IsVbKeyword ( name ) ) { name = " " + name ; } } else using ( var codeProvider = new VBCodeProvider ( ) ) { if ( ( ! char . IsLetter ( name [ 0 ] ) && name [ 0 ] != ' ' ) || ! codeProvider . IsValidIdentifier ( name ) ) { name = " " + name ; } } endif return name ; }
Removes any invalid characters from the name of an database artifact.
Removes any invalid characters from the name of an database artifact .
The scrubbed name.
The scrubbed name .
name
string
The name to be scrubbed.
The name to be scrubbed .