docs2/site/docs/analyzers/gql016.md
| Value | |
|---|---|
| Rule ID | GQL016 |
| Category | Usage |
| Default severity | Error |
| Enabled by default | Yes |
| Code fix provided | No |
| Introduced in | v8.0 |
This rule is triggered when a type implementing an interface is required to have a public parameterless constructor but does not have one.
Certain APIs provided by the GraphQL.NET library require that types implementing an interface must have a parameterless constructor. This rule ensures compliance by verifying the presence of such a constructor and reporting an error if the type does not meet this requirement.
Define parameterless constructor on the type or remove all the constructors.
public class MyComplexityAnalyzer : IFieldComplexityAnalyzer
{
public MyComplexityAnalyzer(ILogger<MyComplexityAnalyzer> logger)
{
}
public FieldComplexityResult Analyze(FieldImpactContext context)
{
return new FieldComplexityResult(10, 1);
}
}
Define parameterless constructor on the type or remove all the constructors.
public class MyComplexityAnalyzer : IFieldComplexityAnalyzer
{
public FieldComplexityResult Analyze(FieldImpactContext context)
{
return new FieldComplexityResult(10, 1);
}
}
If you just want to suppress a single violation, add preprocessor directives to your source file to disable and then re-enable the rule.
#pragma warning disable GQL016
// The code that's violating the rule is on this line.
#pragma warning restore GQL016
To disable the rule for a file, folder, or project, set its severity to none
in the
configuration file.
[*.cs]
dotnet_diagnostic.GQL016.severity = none
For more information, see How to suppress code analysis warnings.