File tree 2 files changed +39
-31
lines changed
2 files changed +39
-31
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
+ // Licensed under the MIT License.
3
+
4
+ using System ;
5
+ using System . Management . Automation ;
6
+
7
+ namespace Microsoft . Windows . PowerShell . ScriptAnalyzer
8
+ {
9
+ internal struct CommandLookupKey : IEquatable < CommandLookupKey >
10
+ {
11
+ private readonly string Name ;
12
+
13
+ private readonly CommandTypes CommandTypes ;
14
+
15
+ internal CommandLookupKey ( string name , CommandTypes ? commandTypes )
16
+ {
17
+ Name = name ;
18
+ CommandTypes = commandTypes ?? CommandTypes . All ;
19
+ }
20
+
21
+ public bool Equals ( CommandLookupKey other )
22
+ {
23
+ return CommandTypes == other . CommandTypes
24
+ && Name . Equals ( other . Name , StringComparison . OrdinalIgnoreCase ) ;
25
+ }
26
+
27
+ public override int GetHashCode ( )
28
+ {
29
+ // Algorithm from https://stackoverflow.com/questions/1646807/quick-and-simple-hash-code-combinations
30
+ unchecked
31
+ {
32
+ int hash = 17 ;
33
+ hash = hash * 31 + Name . ToUpperInvariant ( ) . GetHashCode ( ) ;
34
+ hash = hash * 31 + CommandTypes . GetHashCode ( ) ;
35
+ return hash ;
36
+ }
37
+ }
38
+ }
39
+ }
Original file line number Diff line number Diff line change @@ -1912,37 +1912,6 @@ public Version GetPSVersion()
1912
1912
}
1913
1913
1914
1914
#endregion Methods
1915
-
1916
- private struct CommandLookupKey : IEquatable < CommandLookupKey >
1917
- {
1918
- private readonly string Name ;
1919
-
1920
- private readonly CommandTypes CommandTypes ;
1921
-
1922
- internal CommandLookupKey ( string name , CommandTypes ? commandTypes )
1923
- {
1924
- Name = name ;
1925
- CommandTypes = commandTypes ?? CommandTypes . All ;
1926
- }
1927
-
1928
- public bool Equals ( CommandLookupKey other )
1929
- {
1930
- return CommandTypes == other . CommandTypes
1931
- && Name . Equals ( other . Name , StringComparison . OrdinalIgnoreCase ) ;
1932
- }
1933
-
1934
- public override int GetHashCode ( )
1935
- {
1936
- // Algorithm from https://stackoverflow.com/questions/1646807/quick-and-simple-hash-code-combinations
1937
- unchecked
1938
- {
1939
- int hash = 17 ;
1940
- hash = hash * 31 + Name . ToUpperInvariant ( ) . GetHashCode ( ) ;
1941
- hash = hash * 31 + CommandTypes . GetHashCode ( ) ;
1942
- return hash ;
1943
- }
1944
- }
1945
- }
1946
1915
}
1947
1916
1948
1917
You can’t perform that action at this time.
0 commit comments