Skip to content

Create Suppressors for Specific Scenarios #4878

Description

@JasonBock

Describe the solution you'd like

If I write this class:

public sealed class BigIntegerData
	: BusinessBase<BigIntegerData>
{
	[Create]
	private void Create() { }

	public static readonly PropertyInfo<BigInteger> ContentsProperty =
		RegisterProperty<BigInteger>(nameof(BigIntegerData.Contents));
	public BigInteger Contents
	{
		get => this.GetProperty(BigIntegerData.ContentsProperty);
		set => this.SetProperty(BigIntegerData.ContentsProperty, value);
	}
}

The Create() method gets a IDE0051 code style issue, because it thinks that the method isn't needed. However, because it's marked with [Create], it will be used by CSLA.

So, one thing that could be done is to create a suppressor - i.e. a class that derives from DiagnosticSuppressor, and looks for methods that are marked with a CSLA operation attribute, and if IDE0051 exists for that method, suppress it.

Granted, this really only becomes visible and loud if you light up certain project properties, like EnforceCodeStyleInBuild, so a minor issue at best.

There's other suppressions you can make for things like IDE0058 as you don't need to capture the return value of AddCsla().

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions