
org.sonar.plugins.csharp.S3598.html Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sonarlint-omnisharp-plugin Show documentation
Show all versions of sonarlint-omnisharp-plugin Show documentation
Code Analyzer based on Omnisharp
Why is this an issue?
When declaring a Windows Communication Foundation (WCF) OperationContract
method as one-way
,
that service method won’t return any result, not even an underlying empty confirmation message. These are fire-and-forget methods that are useful in
event-like communication. Therefore, specifying a return type has no effect and can confuse readers.
Exceptions
The rule doesn’t report if OperationContractAttribute.AsyncPattern
is set to true
.
How to fix it
Code examples
Noncompliant code example
[ServiceContract]
interface IMyService
{
[OperationContract(IsOneWay = true)]
int SomethingHappened(int parameter); // Noncompliant
}
Compliant solution
[ServiceContract]
interface IMyService
{
[OperationContract(IsOneWay = true)]
void SomethingHappened(int parameter);
}
Resources
Documentation
Microsoft Learn - OperationContractAttribute
© 2015 - 2025 Weber Informatics LLC | Privacy Policy