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
/// Prevents the use of default expressions and literals on struct WrapperValueObject types, so that validation cannot be circumvented.
10
+
/// Prevents the use of default expressions and literals on struct ValueObject and WrapperValueObject types, so that validation cannot be circumvented.
title:"Default expression instantiating unvalidated value object",
20
20
messageFormat:"A 'default' expression would create an unvalidated instance of value object {0}. Use a parameterized constructor, or use IsDefault() to merely compare.",
{Arity:0,Name:"ValueObjectAttribute",ContainingNamespace:{Name:"DomainModeling",ContainingNamespace:{Name:"Architect",ContainingNamespace.IsGlobalNamespace:true,}},} or
context.ReportDiagnostic("ValueObjectGeneratorValueType","Source-generated struct value object",
188
-
"The type was not source-generated because it is a struct, while a class was expected. To disable source generation, remove the 'partial' keyword.",DiagnosticSeverity.Warning,type);
{(isComparable?"":"/* Generated only if the ValueObject implements IComparable<T> against its own type and each data member implements IComparable<T> against its own type")}
333
-
public int CompareTo({typeName}? other)
327
+
public int CompareTo({typeName}{(isClass?"?":"")} other)
334
328
{{
335
-
if (other is null) return +1;
336
-
337
-
{compareToBodyIfInstanceNonNull}
329
+
{(!generatable.IsClass?"":"if (other is null) return +1;\n\t\t\t")}{compareToBodyIfInstanceNonNull}
{(existingComponents.HasFlags(ValueObjectTypeComponents.EqualsOperator)?"//":"")}public static bool operator ==({typeName}? left, {typeName}? right) => left is null ? right is null : left.Equals(right);
[SuppressMessage("Design","ValueObjectDefaultExpression:Default expression instantiating unvalidated value object",Justification="Testing presence of warning.")]
@@ -115,11 +122,11 @@ internal sealed class TestDbContext(
115
122
[SuppressMessage("CodeQuality","IDE0079:Remove unnecessary suppression",Justification="Suppression is necessary.")]
116
123
[SuppressMessage("Usage","CA2263:Prefer generic overload when type is known",Justification="We have no generic info for types received from callbacks.")]
// Pre-EF10 workaround for ComplexProperty() bug that requires ConstructorBindingConvention to be present (but it can fail if run before UninitializedInstantiationConvention): https://github.com/dotnet/efcore/issues/32437
0 commit comments