I have this API function:
public ResultEnum DoSomeAction(string a, string b, DateTime c, OtherEnum d,
string e, string f, out Guid code)
Why not just make an interface that enforces immutability (i.e. only getters)?
It's essentially your first solution, but you force the function to use the interface to access the parameter.
public interface IDoSomeActionParameters
{
string A { get; }
string B { get; }
DateTime C { get; }
OtherEnum D { get; }
string E { get; }
string F { get; }
}
public class DoSomeActionParameters: IDoSomeActionParameters
{
public string A { get; set; }
public string B { get; set; }
public DateTime C { get; set; }
public OtherEnum D { get; set; }
public string E { get; set; }
public string F { get; set; }
}
and the function declaration becomes:
public ResultEnum DoSomeAction(IDoSomeActionParameters parameters, out Guid code)
Pros:
struct
solutionCons:
DoSomeActionParameters
is a class that could be mapped to IDoSomeActionParameters