Adding sortable tag field support & UNF support by slorello89 · Pull Request #1862 · StackExchange/StackExchange.Redis (original) (raw)
The main problem I can see here is the breaking change on TextField's ctor and the AddSortableTextField method which is going to cause MissingMethodException on anything that takes a transient dependency (i.e. not rebuilt explicitly). We usually try hard to avoid hard breaks, with the preferred method being: to add overloads rather than optional args.
For example:
- public TextField(string name, double weight = 1.0, bool sortable = false, bool noStem = false, bool noIndex = false)
- : base(name, FieldType.FullText, sortable, noIndex)
- public TextField(string name, double weight = 1.0, bool sortable = false, bool noStem = false, bool noIndex = false, bool unf = false)
- : base(name, FieldType.FullText, sortable, noIndex, unf)
could be achieved instead via:
public TextField(string name, double weight, bool sortable, bool noStem, bool noIndex) : this(name, weight, sortable, noStem, noIndex, false) {} public TextField(string name, double weight = 1.0, bool sortable = false, bool noStem = false, bool noIndex = false, bool unf = false)
- by adding the overload, we don't break existing code (noting that adding/removing default parameter values does not cause a
MissingMethodException) - by removing the parameter defaults, we ensure that most rebuilt new code goes to the new method, and doesn't pay any indirection overhead
Likewise:
- public Schema AddSortableTextField(string name, double weight = 1.0)
- public Schema AddSortableTextField(string name, double weight = 1.0, bool unf = false)
could be
public Schema AddSortableTextField(string name, double weight) => AddSortableTextField(name, weight, false); public Schema AddSortableTextField(string name, double weight = 1.0, bool unf = false)