A one-way service operation declares a return value, which the service host rejects
What it finds
A WCF operation marked [OperationContract(IsOneWay = true)] sends no reply, so it cannot return a value; the service fails to start with an InvalidOperationException when its contract declares one. A one-way operation returns void, or in its asynchronous forms IAsyncResult or a plain Task.
From the rule's source, one_way_operation_returns_value.rs.
using System.ServiceModel; [ServiceContract]public interface IOrders{ [OperationContract(IsOneWay = true)] int Submit(string order);tx0 reports: one-way operation Submit returns int [OperationContract(IsOneWay = true)] void Cancel(string order); [OperationContract(IsOneWay = false)] int Count(); [OperationContract] string Status(string order);} Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/csharp:one-way-operation-returns-value" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/csharp:one-way-operation-returns-value] reason="..."tx0 explain tx0/csharp:one-way-operation-returns-value shows the same in the terminal. Found a false positive? Report it.