Code inspection: One way operations must not return values

Last modified: 08 April 2024

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:

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