Skip to content

Commit b010ab4

Browse files
committed
Switched back to block scoped namespaces due to external source usage
1 parent 3a8a313 commit b010ab4

18 files changed

Lines changed: 2256 additions & 2256 deletions

src/Bannerlord.ModuleManager.Models/ApplicationVersion.cs

Lines changed: 115 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -27,141 +27,141 @@
2727
#pragma warning disable
2828
#endif
2929

30-
namespace Bannerlord.ModuleManager;
31-
32-
using System;
30+
namespace Bannerlord.ModuleManager
31+
{
32+
using System;
3333

3434
#if !BANNERLORDBUTRMODULEMANAGER_PUBLIC
3535
internal
3636
#else
37-
public
37+
public
3838
# endif
39-
record ApplicationVersion : IComparable<ApplicationVersion>
40-
{
41-
public static ApplicationVersion Empty { get; } = new();
42-
43-
public ApplicationVersionType ApplicationVersionType { get; set; }
44-
public int Major { get; set; }
45-
public int Minor { get; set; }
46-
public int Revision { get; set; }
47-
public int ChangeSet { get; set; }
48-
49-
public ApplicationVersion() { }
50-
public ApplicationVersion(ApplicationVersionType applicationVersionType, int major, int minor, int revision, int changeSet)
39+
record ApplicationVersion : IComparable<ApplicationVersion>
5140
{
52-
ApplicationVersionType = applicationVersionType;
53-
Major = major;
54-
Minor = minor;
55-
Revision = revision;
56-
ChangeSet = changeSet;
57-
}
41+
public static ApplicationVersion Empty { get; } = new();
5842

59-
public bool IsSame(ApplicationVersion? other) =>
60-
Major == other?.Major && Minor == other.Minor && Revision == other.Revision;
43+
public ApplicationVersionType ApplicationVersionType { get; set; }
44+
public int Major { get; set; }
45+
public int Minor { get; set; }
46+
public int Revision { get; set; }
47+
public int ChangeSet { get; set; }
6148

62-
public bool IsSameWithChangeSet(ApplicationVersion? other) =>
63-
Major == other?.Major && Minor == other.Minor && Revision == other.Revision && ChangeSet == other.ChangeSet;
64-
65-
public override string ToString()
66-
{
67-
// Most user mods skip this, so to be user-friendly we can omit it if it was not originally specified.
68-
return ChangeSet == 0
69-
? $"{GetPrefix(ApplicationVersionType)}{Major}.{Minor}.{Revision}"
70-
: $"{GetPrefix(ApplicationVersionType)}{Major}.{Minor}.{Revision}.{ChangeSet}";
71-
}
72-
public string ToStringWithoutChangeset() => $"{GetPrefix(ApplicationVersionType)}{Major}.{Minor}.{Revision}";
73-
74-
public int CompareTo(ApplicationVersion? other) => ApplicationVersionComparer.CompareStandard(this, other);
75-
76-
public static bool operator <(ApplicationVersion left, ApplicationVersion right) => left.CompareTo(right) < 0;
77-
public static bool operator >(ApplicationVersion left, ApplicationVersion right) => left.CompareTo(right) > 0;
78-
public static bool operator <=(ApplicationVersion left, ApplicationVersion right) => left.CompareTo(right) <= 0;
79-
public static bool operator >=(ApplicationVersion left, ApplicationVersion right) => left.CompareTo(right) >= 0;
49+
public ApplicationVersion() { }
50+
public ApplicationVersion(ApplicationVersionType applicationVersionType, int major, int minor, int revision, int changeSet)
51+
{
52+
ApplicationVersionType = applicationVersionType;
53+
Major = major;
54+
Minor = minor;
55+
Revision = revision;
56+
ChangeSet = changeSet;
57+
}
8058

81-
public static char GetPrefix(ApplicationVersionType applicationVersionType) => applicationVersionType switch
82-
{
83-
ApplicationVersionType.Alpha => 'a',
84-
ApplicationVersionType.Beta => 'b',
85-
ApplicationVersionType.EarlyAccess => 'e',
86-
ApplicationVersionType.Release => 'v',
87-
ApplicationVersionType.Development => 'd',
88-
_ => 'i'
89-
};
90-
91-
public static ApplicationVersionType FromPrefix(char applicationVersionType) => applicationVersionType switch
92-
{
93-
'a' => ApplicationVersionType.Alpha,
94-
'b' => ApplicationVersionType.Beta,
95-
'e' => ApplicationVersionType.EarlyAccess,
96-
'v' => ApplicationVersionType.Release,
97-
'd' => ApplicationVersionType.Development,
98-
_ => ApplicationVersionType.Invalid
99-
};
59+
public bool IsSame(ApplicationVersion? other) =>
60+
Major == other?.Major && Minor == other.Minor && Revision == other.Revision;
10061

101-
public static bool TryParse(string? versionAsString, out ApplicationVersion version) => TryParse(versionAsString, out version, true);
62+
public bool IsSameWithChangeSet(ApplicationVersion? other) =>
63+
Major == other?.Major && Minor == other.Minor && Revision == other.Revision && ChangeSet == other.ChangeSet;
10264

103-
public static bool TryParse(string? versionAsString, out ApplicationVersion version, bool asMin)
104-
{
105-
var major = asMin ? 0 : int.MaxValue;
106-
var minor = asMin ? 0 : int.MaxValue;
107-
var revision = asMin ? 0 : int.MaxValue;
108-
var changeSet = asMin ? 0 : int.MaxValue;
109-
var skipCheck = false;
110-
version = Empty;
111-
if (versionAsString is null)
112-
return false;
113-
114-
var array = versionAsString.Split('.');
115-
if (array.Length != 3 && array.Length != 4 && array[0].Length == 0)
116-
return false;
117-
118-
var applicationVersionType = FromPrefix(array[0][0]);
119-
if (!skipCheck && !int.TryParse(array[0].Substring(1), out major))
120-
{
121-
if (array[0].Substring(1) != "*") return false;
122-
major = int.MinValue;
123-
minor = int.MinValue;
124-
revision = int.MinValue;
125-
changeSet = int.MinValue;
126-
skipCheck = true;
127-
}
128-
if (!skipCheck && !int.TryParse(array[1], out minor))
65+
public override string ToString()
12966
{
130-
if (array[1] != "*") return false;
131-
minor = asMin ? 0 : int.MaxValue;
132-
revision = asMin ? 0 : int.MaxValue;
133-
changeSet = asMin ? 0 : int.MaxValue;
134-
skipCheck = true;
135-
}
136-
if (!skipCheck && !int.TryParse(array[2], out revision))
137-
{
138-
if (array[2] != "*") return false;
139-
revision = asMin ? 0 : int.MaxValue;
140-
changeSet = asMin ? 0 : int.MaxValue;
141-
skipCheck = true;
67+
// Most user mods skip this, so to be user-friendly we can omit it if it was not originally specified.
68+
return ChangeSet == 0
69+
? $"{GetPrefix(ApplicationVersionType)}{Major}.{Minor}.{Revision}"
70+
: $"{GetPrefix(ApplicationVersionType)}{Major}.{Minor}.{Revision}.{ChangeSet}";
14271
}
72+
public string ToStringWithoutChangeset() => $"{GetPrefix(ApplicationVersionType)}{Major}.{Minor}.{Revision}";
73+
74+
public int CompareTo(ApplicationVersion? other) => ApplicationVersionComparer.CompareStandard(this, other);
75+
76+
public static bool operator <(ApplicationVersion left, ApplicationVersion right) => left.CompareTo(right) < 0;
77+
public static bool operator >(ApplicationVersion left, ApplicationVersion right) => left.CompareTo(right) > 0;
78+
public static bool operator <=(ApplicationVersion left, ApplicationVersion right) => left.CompareTo(right) <= 0;
79+
public static bool operator >=(ApplicationVersion left, ApplicationVersion right) => left.CompareTo(right) >= 0;
14380

144-
if (!skipCheck && array.Length == 4 && !int.TryParse(array[3], out changeSet))
81+
public static char GetPrefix(ApplicationVersionType applicationVersionType) => applicationVersionType switch
14582
{
146-
if (array[3] != "*") return false;
147-
changeSet = asMin ? 0 : int.MaxValue;
148-
skipCheck = true;
149-
}
83+
ApplicationVersionType.Alpha => 'a',
84+
ApplicationVersionType.Beta => 'b',
85+
ApplicationVersionType.EarlyAccess => 'e',
86+
ApplicationVersionType.Release => 'v',
87+
ApplicationVersionType.Development => 'd',
88+
_ => 'i'
89+
};
15090

151-
version = new ApplicationVersion
91+
public static ApplicationVersionType FromPrefix(char applicationVersionType) => applicationVersionType switch
15292
{
153-
ApplicationVersionType = applicationVersionType,
154-
Major = major,
155-
Minor = minor,
156-
Revision = revision,
157-
ChangeSet = changeSet
93+
'a' => ApplicationVersionType.Alpha,
94+
'b' => ApplicationVersionType.Beta,
95+
'e' => ApplicationVersionType.EarlyAccess,
96+
'v' => ApplicationVersionType.Release,
97+
'd' => ApplicationVersionType.Development,
98+
_ => ApplicationVersionType.Invalid
15899
};
159100

160-
return true;
161-
}
162-
}
101+
public static bool TryParse(string? versionAsString, out ApplicationVersion version) => TryParse(versionAsString, out version, true);
163102

103+
public static bool TryParse(string? versionAsString, out ApplicationVersion version, bool asMin)
104+
{
105+
var major = asMin ? 0 : int.MaxValue;
106+
var minor = asMin ? 0 : int.MaxValue;
107+
var revision = asMin ? 0 : int.MaxValue;
108+
var changeSet = asMin ? 0 : int.MaxValue;
109+
var skipCheck = false;
110+
version = Empty;
111+
if (versionAsString is null)
112+
return false;
113+
114+
var array = versionAsString.Split('.');
115+
if (array.Length != 3 && array.Length != 4 && array[0].Length == 0)
116+
return false;
117+
118+
var applicationVersionType = FromPrefix(array[0][0]);
119+
if (!skipCheck && !int.TryParse(array[0].Substring(1), out major))
120+
{
121+
if (array[0].Substring(1) != "*") return false;
122+
major = int.MinValue;
123+
minor = int.MinValue;
124+
revision = int.MinValue;
125+
changeSet = int.MinValue;
126+
skipCheck = true;
127+
}
128+
if (!skipCheck && !int.TryParse(array[1], out minor))
129+
{
130+
if (array[1] != "*") return false;
131+
minor = asMin ? 0 : int.MaxValue;
132+
revision = asMin ? 0 : int.MaxValue;
133+
changeSet = asMin ? 0 : int.MaxValue;
134+
skipCheck = true;
135+
}
136+
if (!skipCheck && !int.TryParse(array[2], out revision))
137+
{
138+
if (array[2] != "*") return false;
139+
revision = asMin ? 0 : int.MaxValue;
140+
changeSet = asMin ? 0 : int.MaxValue;
141+
skipCheck = true;
142+
}
143+
144+
if (!skipCheck && array.Length == 4 && !int.TryParse(array[3], out changeSet))
145+
{
146+
if (array[3] != "*") return false;
147+
changeSet = asMin ? 0 : int.MaxValue;
148+
skipCheck = true;
149+
}
150+
151+
version = new ApplicationVersion
152+
{
153+
ApplicationVersionType = applicationVersionType,
154+
Major = major,
155+
Minor = minor,
156+
Revision = revision,
157+
ChangeSet = changeSet
158+
};
159+
160+
return true;
161+
}
162+
}
164163
#nullable restore
165164
#if !BANNERLORDBUTRMODULEMANAGER_ENABLE_WARNING
166165
#pragma warning restore
167-
#endif
166+
#endif
167+
}

src/Bannerlord.ModuleManager.Models/ApplicationVersionComparer.cs

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -27,55 +27,55 @@
2727
#pragma warning disable
2828
#endif
2929

30-
namespace Bannerlord.ModuleManager;
31-
32-
using System.Collections;
33-
using System.Collections.Generic;
30+
namespace Bannerlord.ModuleManager
31+
{
32+
using System.Collections;
33+
using System.Collections.Generic;
3434

3535
#if !BANNERLORDBUTRMODULEMANAGER_PUBLIC
3636
internal
3737
#else
38-
public
38+
public
3939
# endif
40-
class ApplicationVersionComparer : IComparer<ApplicationVersion?>, IComparer
41-
{
42-
/// <inheritdoc/>
43-
public int Compare(object? x, object? y) => Compare(x as ApplicationVersion, y as ApplicationVersion);
40+
class ApplicationVersionComparer : IComparer<ApplicationVersion?>, IComparer
41+
{
42+
/// <inheritdoc/>
43+
public int Compare(object? x, object? y) => Compare(x as ApplicationVersion, y as ApplicationVersion);
4444

45-
/// <inheritdoc/>
46-
public virtual int Compare(ApplicationVersion? x, ApplicationVersion? y) => CompareStandard(x, y);
45+
/// <inheritdoc/>
46+
public virtual int Compare(ApplicationVersion? x, ApplicationVersion? y) => CompareStandard(x, y);
4747

48-
public static int CompareStandard(ApplicationVersion? x, ApplicationVersion? y)
49-
{
50-
if (x is null && y is null)
51-
return 0;
48+
public static int CompareStandard(ApplicationVersion? x, ApplicationVersion? y)
49+
{
50+
if (x is null && y is null)
51+
return 0;
5252

53-
if (x is null)
54-
return -1;
53+
if (x is null)
54+
return -1;
5555

56-
if (y is null)
57-
return 1;
56+
if (y is null)
57+
return 1;
5858

59-
var versionTypeComparison = x.ApplicationVersionType.CompareTo(y.ApplicationVersionType);
60-
if (versionTypeComparison != 0) return versionTypeComparison;
59+
var versionTypeComparison = x.ApplicationVersionType.CompareTo(y.ApplicationVersionType);
60+
if (versionTypeComparison != 0) return versionTypeComparison;
6161

62-
var majorComparison = x.Major.CompareTo(y.Major);
63-
if (majorComparison != 0) return majorComparison;
62+
var majorComparison = x.Major.CompareTo(y.Major);
63+
if (majorComparison != 0) return majorComparison;
6464

65-
var minorComparison = x.Minor.CompareTo(y.Minor);
66-
if (minorComparison != 0) return minorComparison;
65+
var minorComparison = x.Minor.CompareTo(y.Minor);
66+
if (minorComparison != 0) return minorComparison;
6767

68-
var revisionComparison = x.Revision.CompareTo(y.Revision);
69-
if (revisionComparison != 0) return revisionComparison;
68+
var revisionComparison = x.Revision.CompareTo(y.Revision);
69+
if (revisionComparison != 0) return revisionComparison;
7070

71-
var changeSetComparison = x.ChangeSet.CompareTo(y.ChangeSet);
72-
if (changeSetComparison != 0) return changeSetComparison;
71+
var changeSetComparison = x.ChangeSet.CompareTo(y.ChangeSet);
72+
if (changeSetComparison != 0) return changeSetComparison;
7373

74-
return 0;
74+
return 0;
75+
}
7576
}
76-
}
77-
7877
#nullable restore
7978
#if !BANNERLORDBUTRMODULEMANAGER_ENABLE_WARNING
8079
#pragma warning restore
81-
#endif
80+
#endif
81+
}

0 commit comments

Comments
 (0)