@@ -375,7 +375,8 @@ public TypeDefinitionsGenerator(
375375 _assembly = assembly ;
376376 _referenceAssemblies = referenceAssemblies ;
377377 _imports = new HashSet < string > ( ) ;
378- _isSystemAssembly = assembly . GetName ( ) . Name ! . StartsWith ( "System." ) ;
378+ _isSystemAssembly = assembly . GetName ( ) . Name ! . StartsWith (
379+ "System." , StringComparison . Ordinal ) ;
379380 }
380381
381382 public bool ExportAll { get ; set ; }
@@ -1030,7 +1031,8 @@ private static bool HasExplicitInterfaceImplementations(Type type, Type interfac
10301031 foreach ( MethodInfo method in type . GetMethods (
10311032 BindingFlags . NonPublic | BindingFlags . Instance | BindingFlags . DeclaredOnly ) )
10321033 {
1033- if ( method . IsFinal && method . IsPrivate && method . Name . StartsWith ( methodNamePrefix ) )
1034+ if ( method . IsFinal && method . IsPrivate &&
1035+ method . Name . StartsWith ( methodNamePrefix , StringComparison . Ordinal ) )
10341036 {
10351037 return true ;
10361038 }
@@ -1137,9 +1139,11 @@ private static bool IsExtensionTargetTypeSupported(Type targetType)
11371139 ( targetType . Namespace == typeof ( System . Collections . IEnumerable ) . Namespace ||
11381140 targetType . Namespace == typeof ( Collection < > ) . Namespace ||
11391141 targetType . Namespace == typeof ( IEnumerable < > ) . Namespace ) ) ||
1140- targetType . Name . StartsWith ( "IAsyncEnumerable`" ) ||
1141- targetType . Name == nameof ( Tuple ) || targetType . Name . StartsWith ( nameof ( Tuple ) + '`' ) ||
1142- targetType . Name == nameof ( Task ) || targetType . Name . StartsWith ( nameof ( Task ) + '`' ) )
1142+ targetType . Name . StartsWith ( "IAsyncEnumerable`" , StringComparison . Ordinal ) ||
1143+ targetType . Name == nameof ( Tuple ) ||
1144+ targetType . Name . StartsWith ( nameof ( Tuple ) + '`' , StringComparison . Ordinal ) ||
1145+ targetType . Name == nameof ( Task ) ||
1146+ targetType . Name . StartsWith ( nameof ( Task ) + '`' , StringComparison . Ordinal ) )
11431147 {
11441148 return false ;
11451149 }
@@ -1185,7 +1189,7 @@ private void ExportTypeMember(ref SourceBuilder s, MemberInfo member, bool asExt
11851189 string modifiers = ( isStatic ? "static " : "" ) +
11861190 ( property . SetMethod == null ? "readonly " : "" ) ;
11871191 string optionalToken = string . Empty ;
1188- if ( propertyType . EndsWith ( UndefinedTypeSuffix ) )
1192+ if ( propertyType . EndsWith ( UndefinedTypeSuffix , StringComparison . Ordinal ) )
11891193 {
11901194 propertyType = propertyType . Substring (
11911195 0 , propertyType . Length - UndefinedTypeSuffix . Length ) ;
@@ -1380,9 +1384,10 @@ private bool IsExcluded(MethodBase method)
13801384 }
13811385
13821386 // Exclude old style Begin/End async methods, as they always have Task-based alternatives.
1383- if ( ( method . Name . StartsWith ( "Begin" ) &&
1387+ if ( ( method . Name . StartsWith ( "Begin" , StringComparison . Ordinal ) &&
13841388 ( method as MethodInfo ) ? . ReturnType . FullName == typeof ( IAsyncResult ) . FullName ) ||
1385- ( method . Name . StartsWith ( "End" ) && methodParams . Length == 1 &&
1389+ ( method . Name . StartsWith ( "End" , StringComparison . Ordinal ) &&
1390+ methodParams . Length == 1 &&
13861391 methodParams [ 0 ] . ParameterType . FullName == typeof ( IAsyncResult ) . FullName ) )
13871392 {
13881393 return true ;
@@ -1527,13 +1532,13 @@ private string GetTSType(ParameterInfo parameter)
15271532 if ( parameter . Position < 0 && method != null )
15281533 {
15291534 if ( parameter . ParameterType . FullName == typeof ( bool ) . FullName &&
1530- parameter . Member . Name . StartsWith ( "Try" ) &&
1535+ parameter . Member . Name . StartsWith ( "Try" , StringComparison . Ordinal ) &&
15311536 method . GetParameters ( ) . Count ( ( p ) => p . IsOut ) == 1 )
15321537 {
15331538 // A method with Try* pattern simply returns the out-value or undefined
15341539 // instead of an object with the bool and out-value properties.
15351540 tsType = GetTSType ( method . GetParameters ( ) . Last ( ) ) ;
1536- if ( ! tsType . EndsWith ( UndefinedTypeSuffix ) )
1541+ if ( ! tsType . EndsWith ( UndefinedTypeSuffix , StringComparison . Ordinal ) )
15371542 {
15381543 tsType += UndefinedTypeSuffix ;
15391544 }
@@ -1549,7 +1554,7 @@ private string GetTSType(ParameterInfo parameter)
15491554 {
15501555 string propertyType = GetTSType ( p ) ;
15511556 string optionalToken = string . Empty ;
1552- if ( propertyType . EndsWith ( UndefinedTypeSuffix ) )
1557+ if ( propertyType . EndsWith ( UndefinedTypeSuffix , StringComparison . Ordinal ) )
15531558 {
15541559 propertyType = propertyType . Substring (
15551560 0 , propertyType . Length - UndefinedTypeSuffix . Length ) ;
@@ -1721,15 +1726,17 @@ private string GetTSType(
17211726 {
17221727 tsType = "() => void" ;
17231728 }
1724- else if ( type . IsGenericType && type . Name . StartsWith ( nameof ( Action ) + "`" ) )
1729+ else if ( type . IsGenericType &&
1730+ type . Name . StartsWith ( nameof ( Action ) + "`" , StringComparison . Ordinal ) )
17251731 {
17261732 NullabilityInfo [ ] ? typeArgsNullability = nullability ? . GenericTypeArguments ;
17271733 string [ ] parameters = type . GetGenericArguments ( ) . Select ( ( t , i ) =>
17281734 $ "arg{ i + 1 } : { GetTSType ( t , typeArgsNullability ? [ i ] , allowTypeParams ) } ")
17291735 . ToArray ( ) ;
17301736 tsType = $ "({ string . Join ( ", " , parameters ) } ) => void";
17311737 }
1732- else if ( type . IsGenericType && type . Name . StartsWith ( "Func`" ) )
1738+ else if ( type . IsGenericType &&
1739+ type . Name . StartsWith ( "Func`" , StringComparison . Ordinal ) )
17331740 {
17341741 Type [ ] typeArgs = type . GetGenericArguments ( ) ;
17351742 NullabilityInfo [ ] ? typeArgsNullability = nullability ? . GenericTypeArguments ;
@@ -1742,7 +1749,8 @@ private string GetTSType(
17421749 allowTypeParams ) ;
17431750 tsType = $ "({ string . Join ( ", " , parameters ) } ) => { returnType } ";
17441751 }
1745- else if ( type . IsGenericType && type . Name . StartsWith ( "Predicate`" ) )
1752+ else if ( type . IsGenericType &&
1753+ type . Name . StartsWith ( "Predicate`" , StringComparison . Ordinal ) )
17461754 {
17471755 Type typeArg = type . GetGenericArguments ( ) [ 0 ] ;
17481756 NullabilityInfo [ ] ? typeArgsNullability = nullability ? . GenericTypeArguments ;
@@ -1851,7 +1859,7 @@ private string GetTSType(
18511859 {
18521860 string elementType =
18531861 GetTSType ( typeArgs [ 0 ] , typeArgsNullability ? [ 0 ] , allowTypeParams ) ;
1854- if ( elementType . EndsWith ( UndefinedTypeSuffix ) )
1862+ if ( elementType . EndsWith ( UndefinedTypeSuffix , StringComparison . Ordinal ) )
18551863 {
18561864 elementType = $ "({ elementType } )";
18571865 }
@@ -1862,7 +1870,7 @@ private string GetTSType(
18621870 {
18631871 string elementType =
18641872 GetTSType ( typeArgs [ 1 ] , typeArgsNullability ? [ 0 ] , allowTypeParams ) ;
1865- if ( elementType . EndsWith ( UndefinedTypeSuffix ) )
1873+ if ( elementType . EndsWith ( UndefinedTypeSuffix , StringComparison . Ordinal ) )
18661874 {
18671875 elementType = $ "({ elementType } )";
18681876 }
@@ -1873,7 +1881,7 @@ private string GetTSType(
18731881 {
18741882 string elementType =
18751883 GetTSType ( typeArgs [ 0 ] , typeArgsNullability ? [ 0 ] , allowTypeParams ) ;
1876- if ( elementType . EndsWith ( UndefinedTypeSuffix ) )
1884+ if ( elementType . EndsWith ( UndefinedTypeSuffix , StringComparison . Ordinal ) )
18771885 {
18781886 elementType = $ "({ elementType } )";
18791887 }
@@ -1935,8 +1943,8 @@ private string GetTSType(
19351943 string valueTSType = GetTSType ( typeArgs [ 1 ] , typeArgsNullability ? [ 1 ] , allowTypeParams ) ;
19361944 tsType = $ "[{ keyTSType } , { valueTSType } ]";
19371945 }
1938- else if ( typeDefinitionName . StartsWith ( "System. Tuple`") ||
1939- typeDefinitionName . StartsWith ( "System. ValueTuple`") )
1946+ else if ( typeDefinitionName . StartsWith ( "System. Tuple`", StringComparison . Ordinal ) ||
1947+ typeDefinitionName . StartsWith ( "System.ValueTuple`" , StringComparison . Ordinal ) )
19401948 {
19411949 IEnumerable < string > itemTSTypes = typeArgs . Select ( ( typeArg , index ) =>
19421950 GetTSType ( typeArg , typeArgsNullability ? [ index ] , allowTypeParams ) ) ;
@@ -1960,7 +1968,7 @@ private string GetTSType(
19601968#if ! ( NETFRAMEWORK || NETSTANDARD )
19611969 ! type . IsGenericTypeParameter && ! type . IsGenericMethodParameter &&
19621970#endif
1963- ! tsType . EndsWith ( UndefinedTypeSuffix ) )
1971+ ! tsType . EndsWith ( UndefinedTypeSuffix , StringComparison . Ordinal ) )
19641972 {
19651973 tsType += UndefinedTypeSuffix ;
19661974 }
@@ -2022,7 +2030,7 @@ static string GetOptionalToken(ParameterInfo parameter, ref string parameterType
20222030 {
20232031 if ( parameter . IsOptional )
20242032 {
2025- if ( parameterType . EndsWith ( UndefinedTypeSuffix ) )
2033+ if ( parameterType . EndsWith ( UndefinedTypeSuffix , StringComparison . Ordinal ) )
20262034 {
20272035 parameterType = parameterType . Substring (
20282036 0 , parameterType . Length - UndefinedTypeSuffix . Length ) ;
@@ -2042,7 +2050,7 @@ static string GetOptionalToken(ParameterInfo parameter, ref string parameterType
20422050 else if ( parameters . Length == 1 )
20432051 {
20442052 string parameterType = GetTSType ( parameters [ 0 ] ) ;
2045- if ( parameterType . StartsWith ( "..." ) )
2053+ if ( parameterType . StartsWith ( "..." , StringComparison . Ordinal ) )
20462054 {
20472055 return $ "...{ TSIdentifier ( parameters [ 0 ] . Name ) } : { parameterType . Substring ( 3 ) } ";
20482056 }
0 commit comments