The guidance generates a shared project containing the operations and scopes of the application.
For example:
public static class Operations
{
public static readonly Operation[] Values = Enum.GetValues<Access>().Select(o => new Operation { Name = o.ToString(), ID = (int)o }).ToArray();
public static readonly string[] Scopes = Array.Empty<string>();
}
This generates the following complaints by SonarQube:
Use an immutable collection or reduce the accessibility of the field(s) 'Values'. ?
Code Smell Minor Open Not assigned 15min effort cwe, unpredictable
Whether SonarQube is correct or not, the code can be generated as follows to avoid these messages:
public static class Operations
{
public static readonly ImmutableArray<Operation> Values = ImmutableArray.CreateRange(Enum.GetValues<Access>().Select(o => new Operation { Name = o.ToString(), ID = (int)o }));
public static readonly ImmutableArray<string> Scopes = ImmutableArray<string>.Empty;
}
Nothing else needs to change. The overhead in release mode is negligible.
The guidance generates a shared project containing the operations and scopes of the application. For example:
This generates the following complaints by SonarQube:
See why SonarQube thinks this is a bad idea.
Whether SonarQube is correct or not, the code can be generated as follows to avoid these messages:
Nothing else needs to change. The overhead in release mode is negligible.