Skip to content

Commit 125aaed

Browse files
Update dependencies (#240)
- Update Maroontress.Oxbind to 2.0.0-alpha - Update the default language level of test cases to C# 13
1 parent c0273c2 commit 125aaed

File tree

12 files changed

+145
-109
lines changed

12 files changed

+145
-109
lines changed

Analyzers/Analyzers.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
<PropertyGroup>
1515
<AnnotationsVersion>1.0.1</AnnotationsVersion>
16-
<OxbindVersion>1.0.3</OxbindVersion>
16+
<OxbindVersion>2.0.0-alpha</OxbindVersion>
1717
</PropertyGroup>
1818

1919
<ItemGroup>

Analyzers/Config/ByteOrderMarkConfig.cs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,24 @@ namespace StyleChecker.Analyzers.Config;
1010
/// The configuration data of ByteOrderMark analyzer.
1111
/// </summary>
1212
[ForElement(Analyzer.DiagnosticId, Namespace)]
13-
public sealed class ByteOrderMarkConfig : AbstractConfig
13+
public sealed class ByteOrderMarkConfig(
14+
[ForAttribute("maxDepth")] BindResult<string>? maxDepthEvent,
15+
[Multiple] IEnumerable<ByteOrderMarkConfig.File> files)
16+
: AbstractConfig
1417
{
15-
#pragma warning disable IDE0052 // Remove unread private members
16-
[ElementSchema]
17-
private static readonly Schema TheSchema = Schema.Of(Multiple.Of<File>());
18-
#pragma warning restore IDE0052 // Remove unread private members
18+
/// <summary>
19+
/// Initializes a new instance of the <see cref="ByteOrderMarkConfig"/>
20+
/// class.
21+
/// </summary>
22+
[Ignored]
23+
public ByteOrderMarkConfig()
24+
: this(null, [])
25+
{
26+
}
1927

20-
[field: ForAttribute("maxDepth")]
21-
private BindEvent<string>? MaxDepthEvent { get; }
28+
private BindResult<string>? MaxDepthEvent { get; } = maxDepthEvent;
2229

23-
[field: ForChild]
24-
private IEnumerable<File> Files { get; } = [];
30+
private IEnumerable<File> Files { get; } = files;
2531

2632
/// <summary>
2733
/// Gets the maximum number of directory levels to search.
@@ -56,13 +62,12 @@ public override IEnumerable<WhereWhy> Validate()
5662
/// Represents the files that must not start with a BOM.
5763
/// </summary>
5864
[ForElement("files", Namespace)]
59-
private sealed class File
65+
public sealed class File([ForAttribute("glob")] string? glob)
6066
{
6167
/// <summary>
6268
/// Gets the glob pattern representing files that are disallowed to
6369
/// start with a BOM.
6470
/// </summary>
65-
[field: ForAttribute("glob")]
66-
public string? Glob { get; }
71+
public string? Glob { get; } = glob;
6772
}
6873
}

Analyzers/Config/DiscardingReturnValueConfig.cs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,21 @@ namespace StyleChecker.Analyzers.Config;
99
/// The configuration data of DiscardingReturnValue analyzer.
1010
/// </summary>
1111
[ForElement("DiscardingReturnValue", Namespace)]
12-
public sealed class DiscardingReturnValueConfig : AbstractConfig
12+
public sealed class DiscardingReturnValueConfig(
13+
[Multiple] IEnumerable<DiscardingReturnValueConfig.Method> methodElements)
14+
: AbstractConfig
1315
{
14-
#pragma warning disable IDE0052 // Remove unread private members
15-
[ElementSchema]
16-
private static readonly Schema TheSchema = Schema.Of(
17-
Multiple.Of<Method>());
18-
#pragma warning restore IDE0052 // Remove unread private members
16+
/// <summary>
17+
/// Initializes a new instance of the <see
18+
/// cref="DiscardingReturnValueConfig"/> class.
19+
/// </summary>
20+
[Ignored]
21+
public DiscardingReturnValueConfig()
22+
: this([])
23+
{
24+
}
1925

20-
[field: ForChild]
21-
private IEnumerable<Method> MethodElements { get; } = [];
26+
private IEnumerable<Method> MethodElements { get; } = methodElements;
2227

2328
/// <summary>
2429
/// Gets the signatures of the methods whose return value must not be
@@ -40,12 +45,11 @@ public IEnumerable<string> GetMethodSignatures()
4045
/// Represents the method whose return value must not be discarded.
4146
/// </summary>
4247
[ForElement("method", Namespace)]
43-
private sealed class Method
48+
public sealed class Method([ForAttribute("id")] string? id)
4449
{
4550
/// <summary>
4651
/// Gets the signature of the method.
4752
/// </summary>
48-
[field: ForAttribute("id")]
49-
public string? Id { get; }
53+
public string? Id { get; } = id;
5054
}
5155
}

Analyzers/Config/LongLineConfig.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,23 @@ namespace StyleChecker.Analyzers.Config;
77
/// The configuration data of LongLine analyzer.
88
/// </summary>
99
[ForElement("LongLine", Namespace)]
10-
public sealed class LongLineConfig : AbstractConfig
10+
public sealed class LongLineConfig(
11+
[ForAttribute("maxLineLength")] BindResult<string>? maxLineLengthResult)
12+
: AbstractConfig
1113
{
1214
private const int DefaultMaxLineLength = 80;
1315

14-
[field: ForAttribute("maxLineLength")]
15-
private BindEvent<string>? MaxLineLengthEvent { get; }
16+
/// <summary>
17+
/// Initializes a new instance of the <see cref="LongLineConfig"/> class.
18+
/// </summary>
19+
[Ignored]
20+
public LongLineConfig()
21+
: this(null)
22+
{
23+
}
24+
25+
private BindResult<string>? MaxLineLengthEvent { get; }
26+
= maxLineLengthResult;
1627

1728
/// <inheritdoc/>
1829
public override IEnumerable<WhereWhy> Validate()

Analyzers/Config/NoDocumentationConfig.cs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,21 @@ namespace StyleChecker.Analyzers.Config;
1010
/// The configuration data of NoDocumentation analyzer.
1111
/// </summary>
1212
[ForElement(Analyzer.DiagnosticId, Namespace)]
13-
public sealed class NoDocumentationConfig : AbstractConfig
13+
public sealed class NoDocumentationConfig(
14+
[Multiple] IEnumerable<NoDocumentationConfig.Ignore> ignoreElements)
15+
: AbstractConfig
1416
{
15-
#pragma warning disable IDE0052 // Remove unread private members
16-
[ElementSchema]
17-
private static readonly Schema TheSchema = Schema.Of(
18-
Multiple.Of<Ignore>());
19-
#pragma warning restore IDE0052 // Remove unread private members
17+
/// <summary>
18+
/// Initializes a new instance of the <see cref="NoDocumentationConfig"/>
19+
/// class.
20+
/// </summary>
21+
[Ignored]
22+
public NoDocumentationConfig()
23+
: this([])
24+
{
25+
}
2026

21-
[field: ForChild]
22-
private IEnumerable<Ignore> IgnoreElements { get; } = [];
27+
private IEnumerable<Ignore> IgnoreElements { get; } = ignoreElements;
2328

2429
/// <summary>
2530
/// Gets the attribute classes, with which the element annotated and
@@ -60,25 +65,26 @@ public override IEnumerable<WhereWhy> Validate()
6065
/// must be ignored.
6166
/// </summary>
6267
[ForElement("ignore", Namespace)]
63-
private sealed class Ignore : Validateable
68+
public sealed class Ignore(
69+
[ForAttribute("with")] string? with,
70+
[ForAttribute("inclusive")] BindResult<string>? inclusiveResult)
71+
: Validateable
6472
{
6573
/// <summary>
6674
/// Gets the attribute class.
6775
/// </summary>
68-
[field: ForAttribute("with")]
69-
public string? With { get; }
76+
public string? With { get; } = with;
7077

7178
/// <summary>
7279
/// Gets whether the element only is ignored or all the elements it
7380
/// contains are ignored.
7481
/// </summary>
75-
[field: ForAttribute("inclusive")]
76-
public BindEvent<string>? InclusiveEvent { get; }
82+
public BindResult<string>? InclusiveResult { get; } = inclusiveResult;
7783

7884
/// <inheritdoc/>
7985
public IEnumerable<WhereWhy> Validate()
8086
=> ParseKit.ValidateBoolean(
81-
InclusiveEvent,
87+
InclusiveResult,
8288
"invalid boolean value of 'inclusive' attribute");
8389

8490
/// <summary>
@@ -91,7 +97,7 @@ public IEnumerable<WhereWhy> Validate()
9197
/// </returns>
9298
public bool IsInclusive()
9399
{
94-
return ParseKit.ToBooleanValue(InclusiveEvent, false);
100+
return ParseKit.ToBooleanValue(InclusiveResult, false);
95101
}
96102
}
97103
}

Analyzers/Config/ParseKit.cs

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ private static readonly IReadOnlyDictionary<string, bool> BooleanMap
2626
/// <summary>
2727
/// Gets the boolean value of the specified BindEvent&lt;string&gt; object.
2828
/// </summary>
29-
/// <param name="ev">
30-
/// The BindEvent&lt;string&gt; object that provides a boolean value.
29+
/// <param name="result">
30+
/// The BindResult&lt;string&gt; object that provides a boolean value.
3131
/// </param>
3232
/// <param name="defaultValue">
3333
/// The default value.
@@ -36,19 +36,21 @@ private static readonly IReadOnlyDictionary<string, bool> BooleanMap
3636
/// The boolean value if the specified BindEvent has a value and the value
3737
/// is parsed successfully and valid, the default value otherwise.
3838
/// </returns>
39-
public static bool ToBooleanValue(BindEvent<string>? ev, bool defaultValue)
39+
public static bool ToBooleanValue(
40+
BindResult<string>? result,
41+
bool defaultValue)
4042
{
41-
return (ev is null)
43+
return (result is null)
4244
? defaultValue
43-
: ParseBoolean(ev.Value) ?? defaultValue;
45+
: ParseBoolean(result.Value) ?? defaultValue;
4446
}
4547

4648
/// <summary>
4749
/// Gets the integer value of the specified BindEvent&lt;string&gt;
4850
/// object.
4951
/// </summary>
5052
/// <param name="ev">
51-
/// The BindEvent&lt;string&gt; object that provides an integer value.
53+
/// The BindResult&lt;string&gt; object that provides an integer value.
5254
/// </param>
5355
/// <param name="defaultValue">
5456
/// The default value.
@@ -63,7 +65,7 @@ public static bool ToBooleanValue(BindEvent<string>? ev, bool defaultValue)
6365
/// otherwise.
6466
/// </returns>
6567
public static int ToIntValue(
66-
BindEvent<string>? ev,
68+
BindResult<string>? ev,
6769
int defaultValue,
6870
Func<int, bool> isValidValue)
6971
{
@@ -81,8 +83,8 @@ public static int ToIntValue(
8183
/// Validates the specified BindEvent&lt;string&gt; object and gets the
8284
/// tuples representing the error information.
8385
/// </summary>
84-
/// <param name="ev">
85-
/// The BindEvent&lt;string&gt; object.
86+
/// <param name="result">
87+
/// The BindResult&lt;string&gt; object.
8688
/// </param>
8789
/// <param name="invalidBooleanValueError">
8890
/// The error message when it is unable to parse a boolean value.
@@ -92,25 +94,25 @@ public static int ToIntValue(
9294
/// object can be parsed successfully. Otherwise, the errors.
9395
/// </returns>
9496
public static IEnumerable<WhereWhy> ValidateBoolean(
95-
BindEvent<string>? ev,
97+
BindResult<string>? result,
9698
string invalidBooleanValueError)
9799
{
98-
if (ev is null)
100+
if (result is null)
99101
{
100102
return NoError;
101103
}
102-
var v = ParseBoolean(ev.Value);
104+
var v = ParseBoolean(result.Value);
103105
return !v.HasValue
104-
? [ToError(ev, invalidBooleanValueError)]
106+
? [ToError(result, invalidBooleanValueError)]
105107
: NoError;
106108
}
107109

108110
/// <summary>
109111
/// Validates the specified BindEvent&lt;string&gt; object and gets the
110112
/// tuples representing the error information.
111113
/// </summary>
112-
/// <param name="ev">
113-
/// The BindEvent&lt;string&gt; object.
114+
/// <param name="result">
115+
/// The BindResult&lt;string&gt; object.
114116
/// </param>
115117
/// <param name="isValidValue">
116118
/// The function that returns whether a value of the argument is valid or
@@ -127,22 +129,24 @@ public static IEnumerable<WhereWhy> ValidateBoolean(
127129
/// can be parsed successfully. Otherwise, the errors.
128130
/// </returns>
129131
public static IEnumerable<WhereWhy> ValidateInt(
130-
BindEvent<string>? ev,
132+
BindResult<string>? result,
131133
Func<int, bool> isValidValue,
132134
string invalidIntegerValueError,
133135
string invalidValueRangeError)
134136
{
135-
return (ev is null)
137+
return (result is null)
136138
? NoError
137-
: (ParseInt(ev.Value) is not {} v)
138-
? [ToError(ev, invalidIntegerValueError)]
139+
: (ParseInt(result.Value) is not {} v)
140+
? [ToError(result, invalidIntegerValueError)]
139141
: !isValidValue(v)
140-
? [ToError(ev, invalidValueRangeError)]
142+
? [ToError(result, invalidValueRangeError)]
141143
: NoError;
142144
}
143145

144-
private static WhereWhy ToError(BindEvent<string> ev, string message)
145-
=> new(ev.Line, ev.Column, $"{message}: '{ev.Value}'");
146+
private static WhereWhy ToError(
147+
BindResult<string> result,
148+
string message)
149+
=> new(result.Line, result.Column, $"{message}: '{result.Value}'");
146150

147151
/// <summary>
148152
/// Gets the integer value that results from parsing the specified string.

Analyzers/Config/RootConfig.cs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,52 +8,52 @@ namespace StyleChecker.Analyzers.Config;
88
/// The root configuration.
99
/// </summary>
1010
[ForElement("config", Namespace)]
11-
public sealed class RootConfig : AbstractConfig
11+
public sealed class RootConfig(
12+
[Optional] ByteOrderMarkConfig? byteOrderMark,
13+
[Optional] DiscardingReturnValueConfig? discardingReturnValue,
14+
[Optional] LongLineConfig? longLine,
15+
[Optional] NoDocumentationConfig? noDocumentation,
16+
[Optional] ThoughtlessNameConfig? thoughtlessName)
17+
: AbstractConfig
1218
{
13-
#pragma warning disable IDE0052 // Remove unread private members
14-
[ElementSchema]
15-
private static readonly Schema TheSchema = Schema.Of(
16-
Optional.Of<ByteOrderMarkConfig>(),
17-
Optional.Of<DiscardingReturnValueConfig>(),
18-
Optional.Of<LongLineConfig>(),
19-
Optional.Of<NoDocumentationConfig>(),
20-
Optional.Of<ThoughtlessNameConfig>());
21-
#pragma warning restore IDE0052 // Remove unread private members
19+
/// <summary>
20+
/// Initializes a new instance of the <see cref="RootConfig"/> class.
21+
/// </summary>
22+
[Ignored]
23+
public RootConfig()
24+
: this(null, null, null, null, null)
25+
{
26+
}
2227

2328
/// <summary>
2429
/// Gets the configuration of LongLine analyzer.
2530
/// </summary>
26-
[field: ForChild]
2731
public ByteOrderMarkConfig ByteOrderMark { get; }
28-
= new ByteOrderMarkConfig();
32+
= byteOrderMark ?? new();
2933

3034
/// <summary>
3135
/// Gets the configuration of ThoughtlessName analyzer.
3236
/// </summary>
33-
[field: ForChild]
3437
public DiscardingReturnValueConfig DiscardingReturnValue { get; }
35-
= new DiscardingReturnValueConfig();
38+
= discardingReturnValue ?? new();
3639

3740
/// <summary>
3841
/// Gets the configuration of LongLine analyzer.
3942
/// </summary>
40-
[field: ForChild]
4143
public LongLineConfig LongLine { get; }
42-
= new LongLineConfig();
44+
= longLine ?? new();
4345

4446
/// <summary>
4547
/// Gets the configuration of NoDocumentation analyzer.
4648
/// </summary>
47-
[field: ForChild]
4849
public NoDocumentationConfig NoDocumentation { get; }
49-
= new NoDocumentationConfig();
50+
= noDocumentation ?? new();
5051

5152
/// <summary>
5253
/// Gets the configuration of ThoughtlessName analyzer.
5354
/// </summary>
54-
[field: ForChild]
5555
public ThoughtlessNameConfig ThoughtlessName { get; }
56-
= new ThoughtlessNameConfig();
56+
= thoughtlessName ?? new();
5757

5858
/// <inheritdoc/>
5959
public override IEnumerable<WhereWhy> Validate()

0 commit comments

Comments
 (0)