
org.sonar.plugins.csharp.S3597.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?
The ServiceContract
attribute specifies that a class or interface defines the communication contract of a Windows Communication
Foundation (WCF) service. The service operations of this class or interface are defined by OperationContract
attributes added to methods.
It doesn’t make sense to define a contract without any service operations; thus, in a ServiceContract
class or interface at least one
method should be annotated with OperationContract
. Similarly, WCF only serves OperationContract
methods that are defined
inside ServiceContract
classes or interfaces; thus, this rule also checks that ServiceContract
is added to the containing
type of OperationContract
methods.
Noncompliant code example
[ServiceContract]
interface IMyService // Noncompliant
{
int MyServiceMethod();
}
Compliant solution
[ServiceContract]
interface IMyService
{
[OperationContract]
int MyServiceMethod();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy