Using the PostSharp libraries, is it possible to make it so that if a certain value is returned from a method? For example, we put an attribute on the argument (which is a number) in the method (where we also return the number): if the number is less than zero, then we return just zero. Or if the argument is a reference type and is null.
ps it is clear that the problem is solved by a line of code in the body of the method, this is just a pseudo-task for which it is convenient to show.
UPD Something like this:
public class FooClass { public FooClass( [NotEmpty] string field ) { FieldStr = field; } public string FooValue( [IfNull("Empty")] string source ) { return source; } public readonly string FieldStr; } internal class IfNullAttribute : Attribute { private string v; public IfNullAttribute(string v) { this.v = v; } public string ReturnValue() => v; }