Skip to content

Commit da740f6

Browse files
committed
Remove diagnostics for better cacheability in source generation
1 parent 29ae066 commit da740f6

13 files changed

+212
-334
lines changed

.github/workflows/stale.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Stale Items
2+
on:
3+
schedule:
4+
- cron: "0 6 * * 0"
5+
6+
workflow_dispatch:
7+
8+
jobs:
9+
stale:
10+
name: Mark and Close Stale Items
11+
runs-on: ubuntu-latest
12+
permissions:
13+
issues: write
14+
pull-requests: write
15+
steps:
16+
- uses: actions/stale@v9
17+
with:
18+
repo-token: ${{ secrets.GITHUB_TOKEN }}
19+
20+
days-before-stale: 365
21+
days-before-close: 45
22+
23+
# Issue configuration
24+
stale-issue-label: "stale"
25+
close-issue-label: "closed:stale"
26+
exempt-issue-labels: "pinned,security,enhancement,bug,backlog,epic"
27+
28+
stale-issue-message: |
29+
## ⏰ Stale Issue
30+
31+
This issue has had no activity for 1 year.
32+
It will be closed in 45 days unless there is new activity.
33+
To keep it open, comment or remove the `stale` label.
34+
35+
close-issue-message: |
36+
## 🔒 Closed: Inactive Issue
37+
38+
Closed after 45 days of inactivity.
39+
To reopen, comment with a reason and a maintainer will review.
40+
41+
# PR configuration
42+
stale-pr-label: "stale"
43+
close-pr-label: "closed:stale"
44+
exempt-pr-labels: "pinned,work-in-progress,ready-for-review"
45+
46+
stale-pr-message: |
47+
## ⏰ Stale Pull Request
48+
49+
No activity for 1 year. Will close in 45 days unless updated.
50+
To keep open, push commits, comment, or remove the `stale` label.
51+
52+
close-pr-message: |
53+
## 🔒 Closed: Inactive PR
54+
55+
Closed after 45 days of inactivity.
56+
To continue, reopen or submit a new PR and reference this one.

Injectio.sln

Lines changed: 0 additions & 71 deletions
This file was deleted.

Injectio.slnx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Solution>
2+
<Folder Name="/Build/">
3+
<File Path=".github/dependabot.yml" />
4+
<File Path=".github/workflows/dotnet.yml" />
5+
<File Path="README.md" />
6+
<File Path="src/Directory.Build.props" />
7+
</Folder>
8+
<Folder Name="/Tests/">
9+
<Project Path="tests/Injectio.Acceptance.Tests/Injectio.Acceptance.Tests.csproj" />
10+
<Project Path="tests/Injectio.Tests.Console/Injectio.Tests.Console.csproj" />
11+
<Project Path="tests/Injectio.Tests.Library/Injectio.Tests.Library.csproj" />
12+
<Project Path="tests/Injectio.Tests/Injectio.Tests.csproj" />
13+
</Folder>
14+
<Project Path="src/Injectio.Attributes/Injectio.Attributes.csproj" />
15+
<Project Path="src/Injectio.Generators/Injectio.Generators.csproj" />
16+
</Solution>

src/Injectio.Generators/DiagnosticDescriptors.cs

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/Injectio.Generators/Extensions/EnumerableExtensions.cs

Lines changed: 32 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -6,57 +6,36 @@ namespace Injectio.Generators.Extensions;
66
[ExcludeFromCodeCoverage]
77
public static class EnumerableExtensions
88
{
9-
public static string ToDelimitedString<T>(this IEnumerable<T> values)
10-
{
11-
return values.ToDelimitedString(",");
12-
}
13-
14-
public static string ToDelimitedString<T>(this IEnumerable<T>? values, string delimiter)
15-
{
16-
if (values is null)
17-
return string.Empty;
18-
19-
var sb = new StringBuilder();
20-
foreach (var i in values)
21-
{
22-
if (sb.Length > 0)
23-
sb.Append(delimiter ?? ",");
24-
sb.Append(i);
25-
}
26-
27-
return sb.ToString();
28-
}
29-
30-
public static string ToDelimitedString(this IEnumerable<string>? values)
31-
{
32-
return values.ToDelimitedString(",");
33-
}
34-
35-
public static string ToDelimitedString(this IEnumerable<string>? values, string? delimiter)
36-
{
37-
return values.ToDelimitedString(delimiter, null);
38-
}
39-
40-
public static string ToDelimitedString(this IEnumerable<string>? values, string? delimiter, Func<string, string>? escapeDelimiter)
41-
{
42-
if (values is null)
43-
return string.Empty;
44-
45-
delimiter ??= ",";
46-
47-
var sb = new StringBuilder();
48-
foreach (var value in values)
49-
{
50-
if (sb.Length > 0)
51-
sb.Append(delimiter);
52-
53-
var v = escapeDelimiter != null
54-
? escapeDelimiter(value ?? string.Empty)
55-
: value ?? string.Empty;
56-
57-
sb.Append(v);
58-
}
59-
60-
return sb.ToString();
61-
}
9+
/// <summary>
10+
/// Concatenates the string representations of the elements in a sequence, using the specified delimiter between each element.
11+
/// </summary>
12+
/// <typeparam name="T">The type of the elements in the sequence.</typeparam>
13+
/// <param name="values">The sequence of values to concatenate. Each value will be converted to a string using its <see cref="object.ToString()"/> method.</param>
14+
/// <param name="delimiter">The string to use as a delimiter between elements. If <see langword="null"/>, a comma (",") is used by default.</param>
15+
/// <returns>
16+
/// A string that consists of the string representations of the elements in <paramref name="values"/> delimited by the <paramref name="delimiter"/> string.
17+
/// If <paramref name="values"/> is empty, returns <see cref="string.Empty"/>.
18+
/// </returns>
19+
/// <remarks>
20+
/// <see langword="null"/> elements in the sequence will be converted to empty strings in the result.
21+
/// This method is equivalent to calling <see cref="string.Join{T}(string, IEnumerable{T})"/> with the provided parameters.
22+
/// </remarks>
23+
public static string ToDelimitedString<T>(this IEnumerable<T?> values, string? delimiter = ",")
24+
=> string.Join(delimiter ?? ",", values);
25+
26+
/// <summary>
27+
/// Concatenates the elements of a string sequence, using the specified delimiter between each element.
28+
/// </summary>
29+
/// <param name="values">The sequence of string values to concatenate.</param>
30+
/// <param name="delimiter">The string to use as a delimiter between elements. If <see langword="null"/>, a comma (",") is used by default.</param>
31+
/// <returns>
32+
/// A string that consists of the elements in <paramref name="values"/> delimited by the <paramref name="delimiter"/> string.
33+
/// If <paramref name="values"/> is empty, returns <see cref="string.Empty"/>.
34+
/// </returns>
35+
/// <remarks>
36+
/// <see langword="null"/> elements in the sequence will be treated as empty strings in the result.
37+
/// This method is equivalent to calling <see cref="string.Join(string, IEnumerable{string})"/> with the provided parameters.
38+
/// </remarks>
39+
public static string ToDelimitedString(this IEnumerable<string?> values, string? delimiter = ",")
40+
=> string.Join(delimiter ?? ",", values);
6241
}

src/Injectio.Generators/Extensions/StringExtensions.cs

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,6 @@ namespace Injectio.Generators.Extensions;
88
[ExcludeFromCodeCoverage]
99
public static class StringExtensions
1010
{
11-
/// <summary>
12-
/// Truncates the specified text.
13-
/// </summary>
14-
/// <param name="text">The text to truncate.</param>
15-
/// <param name="keep">The number of characters to keep.</param>
16-
/// <param name="ellipsis">The ellipsis string to use when truncating. (Default ...)</param>
17-
/// <returns>
18-
/// A truncate string.
19-
/// </returns>
20-
public static string Truncate(this string? text, int keep, string ellipsis = "...")
21-
{
22-
if (string.IsNullOrEmpty(text))
23-
return string.Empty;
24-
25-
if (string.IsNullOrEmpty(ellipsis))
26-
ellipsis = string.Empty;
27-
28-
if (text!.Length <= keep)
29-
return text;
30-
31-
if (text.Length <= keep + ellipsis.Length || keep < ellipsis.Length)
32-
return text.Substring(0, keep);
33-
34-
return string.Concat(text.Substring(0, keep - ellipsis.Length), ellipsis);
35-
}
36-
3711
/// <summary>
3812
/// Indicates whether the specified String object is null or an empty string
3913
/// </summary>
@@ -55,14 +29,7 @@ public static bool IsNullOrEmpty(this string? item)
5529
/// </returns>
5630
public static bool IsNullOrWhiteSpace(this string? item)
5731
{
58-
if (item == null)
59-
return true;
60-
61-
for (int i = 0; i < item.Length; i++)
62-
if (!char.IsWhiteSpace(item[i]))
63-
return false;
64-
65-
return true;
32+
return string.IsNullOrWhiteSpace(item);
6633
}
6734

6835
/// <summary>
@@ -123,19 +90,4 @@ public static IndentedStringBuilder AppendLineIf(this IndentedStringBuilder sb,
12390

12491
return sb;
12592
}
126-
127-
128-
/// <summary>
129-
/// Converts the specified <paramref name="text"/> into spaced words.
130-
/// </summary>
131-
/// <param name="text">The text to convert.</param>
132-
/// <returns>The text with a space before every capital letter</returns>
133-
public static string? ToTitle(this string? text)
134-
{
135-
if (string.IsNullOrWhiteSpace(text) || text?.Length < 2)
136-
return text;
137-
138-
var words = Regex.Matches(text, "([A-Z][a-z]*)|([0-9]+)") as IEnumerable<Match>;
139-
return string.Join(" ", words.Select(w => w.Value));
140-
}
14193
}

src/Injectio.Generators/ServiceRegistrationContext.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Injectio.Generators;
66

77
public record ServiceRegistrationContext(
8-
EquatableArray<Diagnostic>? Diagnostics = null,
98
EquatableArray<ServiceRegistration>? ServiceRegistrations = null,
109
EquatableArray<ModuleRegistration>? ModuleRegistrations = null
1110
);

0 commit comments

Comments
 (0)