It won't work like that. The new X() { } is an initializer, and you can't split it up by calling a Fix around the constructor then the property / field bindings on the result. Property / field bindings must be evaluated before calling the Fix function.
You'd have to do this:
public Cat Fix(Cat cat) { ... }
cats.Add(Fix(new Cat("happy") { Mean=false }));
Or an extension method like this:
public static class CatExtensions {
public static Cat Fix(this Cat cat) { ... }
}
cats.Add(new Cat("happy") { Mean=false }.Fix());
Or if you are a little more adventurous, you can accept an dynamic type:
public Cat Fix(Cat cat, dynamic properties) { ... }
cats.Add(Fix(new Cat("happy"), new { Mean=false }));
// extension method:
public static class CatExtensions {
public static Cat Fix(this Cat cat, dynamic properties) { ... }
}
cats.Add(new Cat("happy").Fix(new { Mean=false }));
Or a generic method:
public Cat Fix<T>(Cat cat, T properties) { ... }
cats.Add(Fix(new Cat("happy"), new { Mean=false }));
// extension method:
public static class CatExtensions {
public static Cat Fix<T>(this Cat cat, T properties) { ... }
}
cats.Add(new Cat("happy").Fix(new { Mean=false }));