Skip to content

Commit 198fbf9

Browse files
committed
wip
1 parent 6b52135 commit 198fbf9

File tree

20 files changed

+127
-121
lines changed

20 files changed

+127
-121
lines changed

.editorconfig

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,6 @@ dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
5858
dotnet_style_prefer_inferred_tuple_names = true:suggestion
5959
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning
6060
dotnet_style_prefer_simplified_interpolation = true:suggestion
61-
62-
# Dispose rules (CA2000 and CA2213) ported to IDE analyzers. We already execute the CA rules on the repo, so disable the IDE ones.
63-
dotnet_diagnostic.IDE0005.severity = none
64-
dotnet_diagnostic.IDE0067.severity = none
65-
dotnet_diagnostic.IDE0068.severity = none
66-
dotnet_diagnostic.IDE0069.severity = none
67-
dotnet_diagnostic.CA1016.severity = none
6861
#### C# Coding Conventions ####
6962

7063
# Prefer "var" everywhere
@@ -162,30 +155,6 @@ resharper_csharp_align_multiline_parameter = true
162155
# Qualify fields with "this."
163156
resharper_csharp_instance_members_qualify_members = field
164157

165-
# IDE0011: Add braces
166-
dotnet_diagnostic.IDE0011.severity = none
167-
168-
# IDE0090: Use 'new(...)'
169-
dotnet_diagnostic.IDE0090.severity = warning
170-
171-
# IDE0041: Use 'is null' check
172-
dotnet_diagnostic.IDE0041.severity = warning
173-
174-
# CA1825: Avoid zero-length array allocations
175-
dotnet_diagnostic.CA1825.severity = warning
176-
177-
# CA1822: Mark members as static
178-
dotnet_diagnostic.CA1822.severity = warning
179-
180-
# CA2208: Instantiate argument exceptions correctly
181-
dotnet_diagnostic.CA2208.severity = warning
182-
183-
# CA1810: Initialize reference type static fields inline
184-
dotnet_diagnostic.CA1810.severity = warning
185-
186-
# CA1816: Dispose methods should call SuppressFinalize
187-
dotnet_diagnostic.CA1816.severity = warning
188-
189158
# IDE0005: Using directive is unnecessary.
190159
dotnet_diagnostic.IDE0005.severity = warning
191160

src/GitVersion.App.Tests/Helpers/ExecutionResults.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ namespace GitVersion.App.Tests;
66

77
public class ExecutionResults(int exitCode, string? output, string? logContents = null)
88
{
9-
public int ExitCode { get; init; } = exitCode;
10-
public string? Output { get; init; } = output;
9+
public int ExitCode { get; } = exitCode;
10+
public string? Output { get; } = output;
1111
public string? Log { get; init; } = logContents;
1212

1313
public GitVersionVariables? OutputVariables

src/GitVersion.Configuration.Tests/Configuration/ConfigurationFileLocatorTests.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ public void DoNotThrowWhenConfigFileIsInSubDirectoryOfRepoPath()
208208
public void NoWarnOnCustomYmlFile()
209209
{
210210
var stringLogger = string.Empty;
211-
void Action(string info) => stringLogger = info;
212211

213212
var logAppender = new TestLogAppender(Action);
214213
var log = new Log(logAppender);
@@ -223,13 +222,15 @@ public void NoWarnOnCustomYmlFile()
223222

224223
configurationProvider.ProvideForDirectory(this.repoPath);
225224
stringLogger.ShouldMatch("No configuration file found, using default configuration");
225+
return;
226+
227+
void Action(string info) => stringLogger = info;
226228
}
227229

228230
[Test]
229231
public void NoWarnOnCustomYmlFileOutsideRepoPath()
230232
{
231233
var stringLogger = string.Empty;
232-
void Action(string info) => stringLogger = info;
233234

234235
var logAppender = new TestLogAppender(Action);
235236
var log = new Log(logAppender);
@@ -245,6 +246,9 @@ public void NoWarnOnCustomYmlFileOutsideRepoPath()
245246

246247
configurationProvider.ProvideForDirectory(this.repoPath);
247248
stringLogger.ShouldMatch("No configuration file found, using default configuration");
249+
return;
250+
251+
void Action(string info) => stringLogger = info;
248252
}
249253

250254
[Test]

src/GitVersion.Configuration.Tests/Configuration/ConfigurationProviderTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ public void NoWarnOnGitVersionYmlFile()
273273
using var _ = this.fileSystem.SetupConfigFile(path: this.repoPath, text: text);
274274

275275
var stringLogger = string.Empty;
276-
void Action(string info) => stringLogger = info;
277276

278277
var logAppender = new TestLogAppender(Action);
279278
var log = new Log(logAppender);
@@ -290,6 +289,9 @@ public void NoWarnOnGitVersionYmlFile()
290289

291290
var filePath = FileSystemHelper.Path.Combine(this.repoPath, ConfigurationFileLocator.DefaultFileName);
292291
stringLogger.ShouldContain($"Using configuration file '{filePath}'");
292+
return;
293+
294+
void Action(string info) => stringLogger = info;
293295
}
294296

295297
[Test]

src/GitVersion.Core.Tests/Core/GitVersionExecutorTests.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ public void CacheFileExistsOnDisk()
130130
""";
131131

132132
var stringBuilder = new StringBuilder();
133-
void Action(string s) => stringBuilder.AppendLine(s);
134133

135134
var logAppender = new TestLogAppender(Action);
136135
this.log = new Log(logAppender);
@@ -156,6 +155,9 @@ public void CacheFileExistsOnDisk()
156155
var logsMessages = stringBuilder.ToString();
157156

158157
logsMessages.ShouldContain("Loading version variables from disk cache file", Case.Insensitive, logsMessages);
158+
return;
159+
160+
void Action(string s) => stringBuilder.AppendLine(s);
159161
}
160162

161163
[Test]
@@ -225,7 +227,6 @@ public void CacheFileExistsOnDiskWhenOverrideConfigIsSpecifiedVersionShouldBeDyn
225227
public void CacheFileIsMissing()
226228
{
227229
var stringBuilder = new StringBuilder();
228-
void Action(string s) => stringBuilder.AppendLine(s);
229230

230231
var logAppender = new TestLogAppender(Action);
231232
this.log = new Log(logAppender);
@@ -241,6 +242,9 @@ public void CacheFileIsMissing()
241242

242243
var logsMessages = stringBuilder.ToString();
243244
logsMessages.ShouldMatch("(?s).*Cache file.*(?-s) not found.*");
245+
return;
246+
247+
void Action(string s) => stringBuilder.AppendLine(s);
244248
}
245249

246250
[TestCase(ConfigurationFileLocator.DefaultFileName)]

src/GitVersion.Core.Tests/IntegrationTests/RepositoryFixtureExtensions.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@ public static void MakeACommit(this RepositoryFixtureBase fixture, string commit
1111
.GetField("diagramBuilder", BindingFlags.Instance | BindingFlags.NonPublic)
1212
?.GetValue(fixture.SequenceDiagram);
1313

14-
string? GetParticipant(string participant) =>
14+
var participant = GetParticipant(fixture.Repository.Head.FriendlyName);
15+
if (participant != null)
16+
diagramBuilder?.AppendLineFormat("{0} -> {0}: Commit '{1}'", participant, commitMsg);
17+
return;
18+
19+
string? GetParticipant(string participantName) =>
1520
(string?)typeof(SequenceDiagram).GetMethod("GetParticipant", BindingFlags.Instance | BindingFlags.NonPublic)
1621
?.Invoke(fixture.SequenceDiagram,
1722
[
18-
participant
23+
participantName
1924
]);
20-
21-
var participant = GetParticipant(fixture.Repository.Head.FriendlyName);
22-
if (participant != null)
23-
diagramBuilder?.AppendLineFormat("{0} -> {0}: Commit '{1}'", participant, commitMsg);
2425
}
2526
}

src/GitVersion.Core.Tests/Logging/LoggerTest.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,22 @@ public void LoggerObscuresPassword(string protocol)
1515
const string password = "password";
1616
var s = string.Empty;
1717

18-
void Action(string info) => s = info;
19-
2018
var logAppender = new TestLogAppender(Action);
2119
var log = new Log(logAppender);
2220

2321
log.Info($"{protocol}://{username}:{password}@workspace.visualstudio.com/DefaultCollection/_git/CAS");
2422

2523
s.Contains(password).ShouldBe(false);
24+
return;
25+
26+
void Action(string info) => s = info;
2627
}
2728

2829
[Test]
2930
public void UsernameWithoutPassword()
3031
{
3132
var s = string.Empty;
3233

33-
void Action(string info) => s = info;
34-
3534
var logAppender = new TestLogAppender(Action);
3635
var log = new Log(logAppender);
3736

@@ -40,5 +39,8 @@ public void UsernameWithoutPassword()
4039
log.Info(repoUrl);
4140

4241
s.Contains(repoUrl).ShouldBe(true);
42+
return;
43+
44+
void Action(string info) => s = info;
4345
}
4446
}

src/GitVersion.Core/Core/RegexPatterns.cs

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -187,48 +187,63 @@ internal static class AssemblyVersion
187187
{
188188
internal static class CSharp
189189
{
190-
public static Regex TriviaRegex { get; } = new(@"
191-
/\*(.*?)\*/ # Block comments: matches /* ... */
192-
|//(.*?)\r?\n # Line comments: matches // ... followed by a newline
193-
|""((\\[^\n]|[^""\n])*)"" # Strings: matches "" ... "" including escaped quotes",
190+
public static Regex TriviaRegex { get; } = new(
191+
"""
192+
/\*(.*?)\*/ # Block comments: matches /* ... */
193+
|//(.*?)\r?\n # Line comments: matches // ... followed by a newline
194+
|"((\\[^\n]|[^"\n])*)" # Strings: matches " ... " including escaped quotes
195+
""",
194196
RegexOptions.Singleline | RegexOptions.IgnorePatternWhitespace | Options);
195197

196-
public static Regex AttributeRegex { get; } = new(@"(?x) # IgnorePatternWhitespace
197-
\[\s*assembly\s*:\s* # The [assembly: part
198-
(System\s*\.\s*Reflection\s*\.\s*)? # The System.Reflection. part (optional)
199-
Assembly(File|Informational)?Version # The attribute AssemblyVersion, AssemblyFileVersion, or AssemblyInformationalVersion
200-
\s*\(\s*\)\s*\] # End brackets ()]",
198+
public static Regex AttributeRegex { get; } = new(
199+
"""
200+
(?x) # IgnorePatternWhitespace
201+
\[\s*assembly\s*:\s* # The [assembly: part
202+
(System\s*\.\s*Reflection\s*\.\s*)? # The System.Reflection. part (optional)
203+
Assembly(File|Informational)?Version # The attribute AssemblyVersion, AssemblyFileVersion, or AssemblyInformationalVersion
204+
\s*\(\s*\)\s*\] # End brackets ()]
205+
""",
201206
RegexOptions.IgnorePatternWhitespace | Options);
202207
}
203208

204209
internal static class FSharp
205210
{
206-
public static Regex TriviaRegex { get; } = new(@"
207-
/\*(.*?)\*/ # Block comments: matches /* ... */
208-
|//(.*?)\r?\n # Line comments: matches // ... followed by a newline
209-
|""((\\[^\n]|[^""\n])*)"" # Strings: matches "" ... "" including escaped quotes",
211+
public static Regex TriviaRegex { get; } = new(
212+
"""
213+
/\*(.*?)\*/ # Block comments: matches /* ... */
214+
|//(.*?)\r?\n # Line comments: matches // ... followed by a newline
215+
|"((\\[^\n]|[^"\n])*)" # Strings: matches " ... " including escaped quotes
216+
""",
210217
RegexOptions.Singleline | RegexOptions.IgnorePatternWhitespace | Options);
211218

212-
public static Regex AttributeRegex { get; } = new(@"(?x) # IgnorePatternWhitespace
213-
\[\s*<\s*assembly\s*:\s* # The [<assembly: part
214-
(System\s*\.\s*Reflection\s*\.\s*)? # The System.Reflection. part (optional)
215-
Assembly(File|Informational)?Version # The attribute AssemblyVersion, AssemblyFileVersion, or AssemblyInformationalVersion
216-
\s*\(\s*\)\s*>\s*\] # End brackets ()>]",
219+
public static Regex AttributeRegex { get; } = new(
220+
"""
221+
(?x) # IgnorePatternWhitespace
222+
\[\s*<\s*assembly\s*:\s* # The [<assembly: part
223+
(System\s*\.\s*Reflection\s*\.\s*)? # The System.Reflection. part (optional)
224+
Assembly(File|Informational)?Version # The attribute AssemblyVersion, AssemblyFileVersion, or AssemblyInformationalVersion
225+
\s*\(\s*\)\s*>\s*\] # End brackets ()>]
226+
""",
217227
RegexOptions.IgnorePatternWhitespace | Options);
218228
}
219229

220230
internal static class VisualBasic
221231
{
222-
public static Regex TriviaRegex { get; } = new(@"
223-
'(.*?)\r?\n # Line comments: matches // ... followed by a newline
224-
|""((\\[^\n]|[^""\n])*)"" # Strings: matches "" ... "" including escaped quotes",
232+
public static Regex TriviaRegex { get; } = new(
233+
"""
234+
'(.*?)\r?\n # Line comments: matches // ... followed by a newline
235+
|"((\\[^\n]|[^"\n])*)" # Strings: matches " ... " including escaped quotes
236+
""",
225237
RegexOptions.Singleline | RegexOptions.IgnorePatternWhitespace | Options);
226238

227-
public static Regex AttributeRegex { get; } = new(@"(?x) # IgnorePatternWhitespace
228-
\<\s*Assembly\s*:\s* # The <Assembly: part
229-
(System\s*\.\s*Reflection\s*\.\s*)? # The System.Reflection. part (optional)
230-
Assembly(File|Informational)?Version # The attribute AssemblyVersion, AssemblyFileVersion, or AssemblyInformationalVersion
231-
\s*\(\s*\)\s*\> # End brackets ()>",
239+
public static Regex AttributeRegex { get; } = new(
240+
"""
241+
(?x) # IgnorePatternWhitespace
242+
\<\s*Assembly\s*:\s* # The <Assembly: part
243+
(System\s*\.\s*Reflection\s*\.\s*)? # The System.Reflection. part (optional)
244+
Assembly(File|Informational)?Version # The attribute AssemblyVersion, AssemblyFileVersion, or AssemblyInformationalVersion
245+
\s*\(\s*\)\s*\> # End brackets ()>
246+
""",
232247
RegexOptions.IgnorePatternWhitespace | Options);
233248
}
234249
}

src/GitVersion.Core/Core/TaggedSemanticVersionService.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ public ILookup<ICommit, SemanticVersionWithTag> GetTaggedSemanticVersions(
2121
DateTimeOffset? notOlderThan,
2222
TaggedSemanticVersions taggedSemanticVersion)
2323
{
24+
return GetElements().SelectMany(elements => elements).Distinct()
25+
.OrderByDescending(element => element.Commit.When)
26+
.ToLookup(element => element.Commit, element => element.SemanticVersion);
27+
2428
IEnumerable<IEnumerable<CommitSemanticVersion>> GetElements()
2529
{
2630
if (taggedSemanticVersion.HasFlag(TaggedSemanticVersions.OfBranch))
@@ -67,10 +71,6 @@ IEnumerable<IEnumerable<CommitSemanticVersion>> GetElements()
6771
);
6872
}
6973
}
70-
71-
return GetElements().SelectMany(elements => elements).Distinct()
72-
.OrderByDescending(element => element.Commit.When)
73-
.ToLookup(element => element.Commit, element => element.SemanticVersion);
7474
}
7575

7676
public ILookup<ICommit, SemanticVersionWithTag> GetTaggedSemanticVersionsOfBranch(

src/GitVersion.Core/Logging/ConsoleAppender.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ namespace GitVersion.Logging;
33
internal class ConsoleAppender : ILogAppender
44
{
55
private readonly object locker = new();
6-
private readonly IDictionary<LogLevel, (ConsoleColor, ConsoleColor)> palettes = CreatePalette();
6+
private readonly Dictionary<LogLevel, (ConsoleColor, ConsoleColor)> palettes = CreatePalette();
77

88
public void WriteTo(LogLevel level, string message)
99
{

0 commit comments

Comments
 (0)