[CSHARP-4100] Review uses of StringComparison in StartsWith, Contains and EndsWith Created: 14/Mar/22  Updated: 28/Oct/23  Resolved: 15/Apr/22

Status: Closed
Project: C# Driver
Component/s: LINQ3
Affects Version/s: None
Fix Version/s: 2.15.1

Type: Task Priority: Major - P3
Reporter: James Kovacs Assignee: Robert Stam
Resolution: Fixed Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by CSHARP-4115 Query against strings (case insensitive) Backlog
Issue split
split to CSHARP-4119 Review Compare, CompareTo and Equals ... Backlog
split to CSHARP-4120 Review IndexOf and LastIndexOf uses o... Backlog
split to CSHARP-4121 Review ToLower and ToUpper uses of Cu... Backlog

 Description   

EqualsMethodToAggregationExpressionTranslator considers StringComparison.CurrentCulture and StringComparison.Ordinal to be equivalent. StartsWithContainsOrEndsWithMethodToAggregationExpressionTranslator considers StringComparison.CurrentCulture to be supported and all other StringComparison values throw ExpressionNotSupportedException. We should review our uses of StringComparison to ensure that they are consistent across the driver.

Note that neither CurrentCulture nor Ordinal truly captures the server semantics. The server does not have an equivalent to Ordinal. Even CurrentCulture isn't quite right as many server functions such as $toLower only have well-defined behaviours for strings of ASCII characters. So we will have to make a design decision regarding how best to represent StringComparison values when translating to MQL or whether we should throw ExpressionNotSupportedExceptions.



 Comments   
Comment by Githook User [ 04/May/22 ]

Author:

{'name': 'rstam', 'email': 'robert@robertstam.org', 'username': 'rstam'}

Message: CSHARP-4100: Skip tests that fail on .NET Core 2.1 due to bugs in .NET Core 2.1.
Branch: v2.15.x
https://github.com/mongodb/mongo-csharp-driver/commit/ae161bc37be3a8eef11a5165e5948b4440e6dd30

Comment by Githook User [ 04/May/22 ]

Author:

{'name': 'rstam', 'email': 'robert@robertstam.org', 'username': 'rstam'}

Message: CSHARP-4100: Some String methods that are defined in .NET Core 2.1 but not in .NET Standard 2.0 have to be handled using reflection.
Branch: v2.15.x
https://github.com/mongodb/mongo-csharp-driver/commit/b98fc4318b74920ff737f8d29bffc2d44777c706

Comment by Githook User [ 04/May/22 ]

Author:

{'name': 'rstam', 'email': 'robert@robertstam.org', 'username': 'rstam'}

Message: CSHARP-4100: Review uses of StringComparison in StartsWith, Contains and EndsWith.
Branch: v2.15.x
https://github.com/mongodb/mongo-csharp-driver/commit/2ac2bad9115416743edbc5c802314651c7797db1

Comment by Githook User [ 15/Apr/22 ]

Author:

{'name': 'rstam', 'email': 'robert@robertstam.org', 'username': 'rstam'}

Message: CSHARP-4100: Skip tests that fail on .NET Core 2.1 due to bugs in .NET Core 2.1.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/ab56c675e8f3975ac4862f6aa049c474198717a8

Comment by Githook User [ 15/Apr/22 ]

Author:

{'name': 'rstam', 'email': 'robert@robertstam.org', 'username': 'rstam'}

Message: CSHARP-4100: Some String methods that are defined in .NET Core 2.1 but not in .NET Standard 2.0 have to be handled using reflection.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/6b50bf4eb099c8d54d06c5318e4b1d83d8802d24

Comment by Githook User [ 15/Apr/22 ]

Author:

{'name': 'rstam', 'email': 'robert@robertstam.org', 'username': 'rstam'}

Message: CSHARP-4100: Review uses of StringComparison in StartsWith, Contains and EndsWith.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/884c6327e5848259c0789dfd28b7e8edd526c5ac

Comment by Robert Stam [ 31/Mar/22 ]

Other methods that have overloads with a `StringComparison` parameter will be reviewed separately.

Generated at Wed Feb 07 21:47:13 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.