ReSharper 2024.1 Help

Code inspection: One way operations must not return values

This inspection reports violations of the IsOneWay=true contract in the System.ServiceModel.OperationContract context.

The IsOneWay=true contract is used in Windows Communication Foundation (WCF) to indicate that an operation should be invoked in a fire-and-forget manner, which means that the client does not wait for a response from the server after invoking the operation.

If a non-void method is annotated this way, you have an inconsistency that might indicate an error.

There are two ways to fix that:

If your intention is to receive a response from the service, remove the IsOneWay=true contract:

[OperationContract(IsOneWay=true)] public string GetString() { return "something"; }
[OperationContract] public string GetString() { return "something"; }

If you intend to keep the one-way operation behavior and don't need the return value, modify the method to return void instead:

[OperationContract(IsOneWay=true)] public string GetString() { return "something"; }
[OperationContract(IsOneWay=true) public void GetString() { /*Do something*/ }
Last modified: 08 April 2024