|
3 | 3 | // See the License.txt file in the project root for more information. |
4 | 4 |
|
5 | 5 | using System; |
6 | | -using System.Diagnostics; |
7 | 6 |
|
8 | | -namespace Microsoft.Build.Tasks.Git |
| 7 | +namespace Microsoft.Build.Tasks.Git; |
| 8 | + |
| 9 | +internal readonly struct GitVariableName(string sectionName, string subsectionName, string variableName) : IEquatable<GitVariableName> |
9 | 10 | { |
10 | | - internal readonly struct GitVariableName : IEquatable<GitVariableName> |
11 | | - { |
12 | | - public static readonly StringComparer SectionNameComparer = StringComparer.OrdinalIgnoreCase; |
13 | | - public static readonly StringComparer SubsectionNameComparer = StringComparer.Ordinal; |
14 | | - public static readonly StringComparer VariableNameComparer = StringComparer.OrdinalIgnoreCase; |
15 | | - |
16 | | - public readonly string SectionName; |
17 | | - public readonly string SubsectionName; |
18 | | - public readonly string VariableName; |
19 | | - |
20 | | - public GitVariableName(string sectionName, string subsectionName, string variableName) |
21 | | - { |
22 | | - NullableDebug.Assert(sectionName != null); |
23 | | - NullableDebug.Assert(subsectionName != null); |
24 | | - NullableDebug.Assert(variableName != null); |
25 | | - |
26 | | - SectionName = sectionName; |
27 | | - SubsectionName = subsectionName; |
28 | | - VariableName = variableName; |
29 | | - } |
30 | | - |
31 | | - public bool SectionNameEquals(string name) |
32 | | - => SectionNameComparer.Equals(SectionName, name); |
33 | | - |
34 | | - public bool SubsectionNameEquals(string name) |
35 | | - => SubsectionNameComparer.Equals(SubsectionName, name); |
36 | | - |
37 | | - public bool VariableNameEquals(string name) |
38 | | - => VariableNameComparer.Equals(VariableName, name); |
39 | | - |
40 | | - public bool Equals(GitVariableName other) |
41 | | - => SectionNameEquals(other.SectionName) && |
42 | | - SubsectionNameEquals(other.SubsectionName) && |
43 | | - VariableNameEquals(other.VariableName); |
44 | | - |
45 | | - public override bool Equals(object? obj) |
46 | | - => obj is GitVariableName other && Equals(other); |
47 | | - |
48 | | - public override int GetHashCode() |
49 | | - => SectionName.GetHashCode() ^ SubsectionName.GetHashCode() ^ VariableName.GetHashCode(); |
50 | | - |
51 | | - public override string ToString() |
52 | | - => (SubsectionName.Length == 0) ? |
53 | | - SectionName + "." + VariableName : |
54 | | - SectionName + "." + SubsectionName + "." + VariableName; |
55 | | - } |
| 11 | + public static readonly StringComparer SectionNameComparer = StringComparer.OrdinalIgnoreCase; |
| 12 | + public static readonly StringComparer SubsectionNameComparer = StringComparer.Ordinal; |
| 13 | + public static readonly StringComparer VariableNameComparer = StringComparer.OrdinalIgnoreCase; |
| 14 | + |
| 15 | + public readonly string SectionName = sectionName; |
| 16 | + public readonly string SubsectionName = subsectionName; |
| 17 | + public readonly string VariableName = variableName; |
| 18 | + |
| 19 | + public bool SectionNameEquals(string name) |
| 20 | + => SectionNameComparer.Equals(SectionName, name); |
| 21 | + |
| 22 | + public bool SubsectionNameEquals(string name) |
| 23 | + => SubsectionNameComparer.Equals(SubsectionName, name); |
| 24 | + |
| 25 | + public bool VariableNameEquals(string name) |
| 26 | + => VariableNameComparer.Equals(VariableName, name); |
| 27 | + |
| 28 | + public bool Equals(GitVariableName other) |
| 29 | + => SectionNameEquals(other.SectionName) && |
| 30 | + SubsectionNameEquals(other.SubsectionName) && |
| 31 | + VariableNameEquals(other.VariableName); |
| 32 | + |
| 33 | + public override bool Equals(object? obj) |
| 34 | + => obj is GitVariableName other && Equals(other); |
| 35 | + |
| 36 | + public override int GetHashCode() |
| 37 | + => SectionNameComparer.GetHashCode(SectionName) ^ |
| 38 | + SubsectionNameComparer.GetHashCode(SubsectionName) ^ |
| 39 | + VariableNameComparer.GetHashCode(VariableName); |
| 40 | + |
| 41 | + public override string ToString() |
| 42 | + => (SubsectionName.Length == 0) ? |
| 43 | + SectionName + "." + VariableName : |
| 44 | + SectionName + "." + SubsectionName + "." + VariableName; |
56 | 45 | } |
0 commit comments