forked from maroontress/StyleChecker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDiscardingReturnValueConfig.cs
More file actions
55 lines (49 loc) · 1.52 KB
/
DiscardingReturnValueConfig.cs
File metadata and controls
55 lines (49 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
namespace StyleChecker.Analyzers.Config;
using System.Collections.Generic;
using System.Linq;
using Maroontress.Oxbind;
using Maroontress.Roastery;
/// <summary>
/// The configuration data of DiscardingReturnValue analyzer.
/// </summary>
[ForElement("DiscardingReturnValue", Namespace)]
public sealed class DiscardingReturnValueConfig(
[Multiple] IEnumerable<DiscardingReturnValueConfig.Method> methodElements)
: AbstractConfig
{
/// <summary>
/// Initializes a new instance of the <see
/// cref="DiscardingReturnValueConfig"/> class.
/// </summary>
[Ignored]
public DiscardingReturnValueConfig()
: this([])
{
}
private IEnumerable<Method> MethodElements { get; } = methodElements;
/// <summary>
/// Gets the signatures of the methods whose return value must not be
/// discarded.
/// </summary>
/// <returns>
/// The signatures of the methods.
/// </returns>
public IEnumerable<string> GetMethodSignatures()
{
return MethodElements.Select(e => e.Id)
.FilterNonNullReference();
}
/// <inheritdoc/>
public override IEnumerable<WhereWhy> Validate() => ParseKit.NoError;
/// <summary>
/// Represents the method whose return value must not be discarded.
/// </summary>
[ForElement("method", Namespace)]
public sealed class Method([ForAttribute("id")] string? id)
{
/// <summary>
/// Gets the signature of the method.
/// </summary>
public string? Id { get; } = id;
}
}