-
Notifications
You must be signed in to change notification settings - Fork 804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use ordinal string comparison in string manipulation methods #4912
Merged
KevinRansom
merged 5 commits into
dotnet:master
from
auduchinok:stringComparison-ordinal
Jun 12, 2018
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
568acd3
Use ordinal string comparison in string manipulation methods
auduchinok c751112
Add StartsWithOrdinal, EndsWithOrdinal extension methods
auduchinok e9527f1
Merge branch 'master' into stringComparison-ordinal
KevinRansom 918c057
Merge branch 'master' into stringComparison-ordinal
KevinRansom 6f9a22b
Merge branch 'master' into stringComparison-ordinal
KevinRansom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -695,7 +695,7 @@ let OutputPhasedErrorR (os:StringBuilder) (err:PhasedDiagnostic) = | |
| ContextInfo.TupleInRecordFields -> | ||
os.Append(ErrorFromAddingTypeEquation1E().Format t2 t1 tpcs) |> ignore | ||
os.Append(System.Environment.NewLine + FSComp.SR.commaInsteadOfSemicolonInRecord()) |> ignore | ||
| _ when t2 = "bool" && t1.EndsWith " ref" -> | ||
| _ when t2 = "bool" && t1.EndsWith(" ref", StringComparison.Ordinal) -> | ||
os.Append(ErrorFromAddingTypeEquation1E().Format t2 t1 tpcs) |> ignore | ||
os.Append(System.Environment.NewLine + FSComp.SR.derefInsteadOfNot()) |> ignore | ||
| _ -> os.Append(ErrorFromAddingTypeEquation1E().Format t2 t1 tpcs) |> ignore | ||
|
@@ -1603,7 +1603,7 @@ let SanitizeFileName fileName implicitIncludeDir = | |
let currentDir = implicitIncludeDir | ||
|
||
// if the file name is not rooted in the current directory, return the full path | ||
if not(fullPath.StartsWith(currentDir)) then | ||
if not(fullPath.StartsWith(currentDir, StringComparison.Ordinal)) then | ||
fullPath | ||
// if the file name is rooted in the current directory, return the relative path | ||
else | ||
|
@@ -1795,7 +1795,7 @@ type private TypeInThisAssembly = class end | |
let GetDefaultSystemValueTupleReference () = | ||
try | ||
let asm = typeof<System.ValueTuple<int, int>>.Assembly | ||
if asm.FullName.StartsWith "System.ValueTuple" then | ||
if asm.FullName.StartsWith("System.ValueTuple", StringComparison.Ordinal) then | ||
Some asm.Location | ||
else | ||
let location = Path.GetDirectoryName(typeof<TypeInThisAssembly>.Assembly.Location) | ||
|
@@ -3752,28 +3752,29 @@ type TcAssemblyResolutions(tcConfig: TcConfig, results: AssemblyResolution list, | |
//-------------------------------------------------------------------------- | ||
|
||
let IsSignatureDataResource (r: ILResource) = | ||
r.Name.StartsWith FSharpSignatureDataResourceName || | ||
r.Name.StartsWith FSharpSignatureDataResourceName2 | ||
r.Name.StartsWith(FSharpSignatureDataResourceName, StringComparison.Ordinal) || | ||
r.Name.StartsWith(FSharpSignatureDataResourceName2, StringComparison.Ordinal) | ||
|
||
let IsOptimizationDataResource (r: ILResource) = | ||
r.Name.StartsWith FSharpOptimizationDataResourceName || | ||
r.Name.StartsWith FSharpOptimizationDataResourceName2 | ||
r.Name.StartsWith(FSharpOptimizationDataResourceName, StringComparison.Ordinal)|| | ||
r.Name.StartsWith(FSharpOptimizationDataResourceName2, StringComparison.Ordinal) | ||
|
||
let GetSignatureDataResourceName (r: ILResource) = | ||
if r.Name.StartsWith FSharpSignatureDataResourceName then | ||
if r.Name.StartsWith(FSharpSignatureDataResourceName, StringComparison.Ordinal) then | ||
String.dropPrefix r.Name FSharpSignatureDataResourceName | ||
elif r.Name.StartsWith FSharpSignatureDataResourceName2 then | ||
elif r.Name.StartsWith(FSharpSignatureDataResourceName2, StringComparison.Ordinal) then | ||
String.dropPrefix r.Name FSharpSignatureDataResourceName2 | ||
else failwith "GetSignatureDataResourceName" | ||
|
||
let GetOptimizationDataResourceName (r: ILResource) = | ||
if r.Name.StartsWith FSharpOptimizationDataResourceName then | ||
if r.Name.StartsWith(FSharpOptimizationDataResourceName, StringComparison.Ordinal) then | ||
String.dropPrefix r.Name FSharpOptimizationDataResourceName | ||
elif r.Name.StartsWith FSharpOptimizationDataResourceName2 then | ||
elif r.Name.StartsWith(FSharpOptimizationDataResourceName2, StringComparison.Ordinal) then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't really know what comparison resource and assembly names should use. My understanding is that it doesn't actually make a difference if the thing being compared with is ASCII |
||
String.dropPrefix r.Name FSharpOptimizationDataResourceName2 | ||
else failwith "GetOptimizationDataResourceName" | ||
|
||
let IsReflectedDefinitionsResource (r: ILResource) = r.Name.StartsWith QuotationPickler.SerializedReflectedDefinitionsResourceNameBase | ||
let IsReflectedDefinitionsResource (r: ILResource) = | ||
r.Name.StartsWith(QuotationPickler.SerializedReflectedDefinitionsResourceNameBase, StringComparison.Ordinal) | ||
|
||
let MakeILResource rname bytes = | ||
{ Name = rname | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add StartsWithOrdinal/EndsWithOrdinal extension methods to illib.fs? Then it's easy to search and remove uses of StartsWith
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.