You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 1702507
Browse filesBrowse the repository at this point in the historyBrowse files
Generator: share repeated code, no change to the generated text (#303)
A refactor of the source generator's own code. The text it emits is
byte-identical to before: the generated file of the generator tests (counters
on and off) and of the generated benchmarks, compared with a recursive diff
before and after, is empty.
What changed:
- The first line of a partial model's Bind is appended as a line of its own,
not through a placeholder that only lined up with the tabs after it.
- A member's read statement takes its ordinal as a parameter. The two-step
replacement of a second placeholder is gone.
- The fully qualified symbol display format is declared once, on ModelReader.
- One helper says whether a type is Nullable<T> and one returns its underlying
type; the three places that spelled it out use them.
- One helper tells whether a member or parameter carries a null policy or null
value attribute.
- One iterator walks a type and its base types; the four loops that did it by
hand use it.
- EquatableArray drops its length, indexer and enumerator, which nothing used.
Items, Equals and GetHashCode, which the incremental cache relies on, are
unchanged.
Looked at and left alone:
- The two query-receiver tests in the interceptor are not repeated (each
appears once, with different sets), so a helper would only add lines.
- The public-setter pattern appears twice as a one-clause test and a third
time inside a pattern a helper cannot replace; the helper would be longer
than the code it replaces.
- The empty strings Site carries for a typed query are documented where they
are made and sit in the cached model; changing them gains nothing.
Checks: whole solution Release build without warnings; generator tests and
core tests in Release; dotnet format style and analyzers on the generator and
its tests.
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
// A member its type declares non-nullable is read as a hand-written reader reads it: its typed getter alone, or a plain cast of GetValue (a NULL makes
859
863
// the getter or the cast throw, and Core's loop reports it). Only where a cast of DBNull would succeed (object, an interface DBNull implements) does a
860
864
// general read check for it and throw SqlNullValueException, as the runtime does, instead of letting DBNull pass as a value.
861
-
// A nullable member is tested for NULL first, and null is stored, so the setter sees it.
return$"{{ object c = r.GetValue({{O}}); {target} = c is null || c is global::System.DBNull ? throw new global::System.Data.SqlTypes.SqlNullValueException() : {required}; }}";
875
+
return$"{{ object c = r.GetValue({o}); {target} = c is null || c is global::System.DBNull ? throw new global::System.Data.SqlTypes.SqlNullValueException() : {required}; }}";
871
876
}
872
877
873
-
if(general)
878
+
if(s.Read.General)
874
879
{
875
880
stringvalue=read.Replace("{0}","c");
876
-
return$"{{ object c = r.GetValue({{O}}); {target} = c is null || c is global::System.DBNull ? default({s.Type}) : {value}; }}";
881
+
return$"{{ object c = r.GetValue({o}); {target} = c is null || c is global::System.DBNull ? default({s.Type}) : {value}; }}";
// speed, never correctness. A positional record's parameter carries its own attributes, and a [property:] target lands on the property: both are seen.
308
308
staticboolDeclaresNullPolicy(INamedTypeSymbolt)
309
309
{
310
-
for(INamedTypeSymbol?c=t;cis not null;c=c.BaseType)
0 commit comments