diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json
index d51c9f0..f8a4785 100644
--- a/.config/dotnet-tools.json
+++ b/.config/dotnet-tools.json
@@ -17,7 +17,7 @@
"rollForward": false
},
"purview.build": {
- "version": "0.5.4",
+ "version": "0.7.1",
"commands": [
"purview-build"
],
diff --git a/.config/purview-build.json b/.config/purview-build.json
index 0e075d2..6dbe328 100644
--- a/.config/purview-build.json
+++ b/.config/purview-build.json
@@ -3,7 +3,7 @@
"Solution": "src/AspireC4.slnx",
"TestRoot": "src/tests",
"TestPatterns": "*Tests.csproj",
- "TestFilter": "/*/*/*/*[Category=Unit]"
+ "TestFilter": "/*/*/*/*"
},
"PackValidation": {
// AspireC4.EntityFrameworkCore is analyzer-only (IncludeBuildOutput=false), so NuGet produces
@@ -25,7 +25,9 @@
// versions forced this check on and could not be configured off, so these packages have
// always been validated against it; declaring it keeps that behaviour. The analyzer-only
// package is unaffected either way: it ships no PDB, so it is never inspected.
- "RequiredCompilerFlags": ["optimization=release"],
+ "RequiredCompilerFlags": [
+ "optimization=release"
+ ],
// RequireExplicitContent defaults to true, so this is the exhaustive declaration of what each
// package ships: a package with no rule here, or an entry matching none of its globs, fails
// validation. The lib/ paths are literal net10.0 and must be updated alongside the target
@@ -74,4 +76,4 @@
"Release": {
"Mode": "None"
}
-}
+}
\ No newline at end of file
diff --git a/.editorconfig b/.editorconfig
index 959b462..b511789 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -1,3 +1,23 @@
+# Purview.BuildSdk 1.1.0 - managed file, do not edit
+#
+# This file is written by Purview.BuildSdk and is replaced whenever the SDK version changes. The version
+# on the first line is how the SDK recognises a file it owns: a .editorconfig without that marker is
+# yours, and is never touched.
+#
+# To add your own rules, create a second .editorconfig in a subdirectory - `src/.editorconfig` is the
+# usual choice - without `root = true`. EditorConfig applies the nearest file last, so your settings win
+# over these, and nothing you write is lost when this file is updated.
+#
+# To stop the SDK updating this file, set one of:
+# false keep this file as it is
+# Never opt out of all bootstrapping
+# false
+#
+# Deleting the first line also works: without the marker the SDK treats the file as yours. You then own
+# every rule in it, including the ones a future SDK version would have fixed.
+#
+# See https://github.com/purview-dev/build-sdk#editorconfig for the full description.
+
root = true
# Base Configuration - General Settings, File Formatting, and Naming Conventions
@@ -27,8 +47,10 @@ dotnet_search_reference_assemblies = true
# Nullability settings
dotnet_build_property.Nullable = enable
-# Enable or disable the analyzers
-dotnet_analyzer_diagnostic.severity = warning
+# Per-rule severity is authoritative in this file. The SDK sets AnalysisMode/AnalysisLevel as
+# MSBuild properties, and the .NET SDK ignores bulk 'dotnet_analyzer_diagnostic.*' severity
+# configuration whenever those properties are present. Do not re-add a bulk entry here: it
+# silently does nothing and hides which severities are actually enforced.
# Visual Studio XML Project Files
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
@@ -76,23 +98,20 @@ indent_style = tab
dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.severity = warning
dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.style = non_private_static_field_style
dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.symbols = non_private_static_fields
-dotnet_naming_rule.private_fields.severity = warning
-dotnet_naming_rule.private_fields.style = camel_case_underscore
-dotnet_naming_rule.private_fields.symbols = private_fields
-dotnet_naming_rule.private_fields_style.severity = warning
-dotnet_naming_rule.private_fields_style.style = camel_case
-dotnet_naming_rule.private_fields_style.symbols = private_fields
dotnet_naming_style.non_private_static_field_style.capitalization = pascal_case
+# NOTE: the private-field rules that used to sit here referenced a style ('camel_case_underscore')
+# and a symbol group ('private_fields') that were never defined, so they never applied. The real
+# private-field rules are declared in the "StyleCop Field Naming Rules" section below.
dotnet_naming_symbols.non_private_static_fields.applicable_accessibilities = public, protected, internal, protected_internal, private_protected
dotnet_naming_symbols.non_private_static_fields.applicable_kinds = field
dotnet_naming_symbols.non_private_static_fields.required_modifiers = static
-# Constants are PascalCase
+# Constants are PascalCase (field constants; local constants are locals and stay camelCase)
dotnet_naming_rule.constants_should_be_pascal_case.severity = warning
dotnet_naming_rule.constants_should_be_pascal_case.style = non_private_static_field_style
dotnet_naming_rule.constants_should_be_pascal_case.symbols = constants
dotnet_naming_style.constant_style.capitalization = pascal_case
-dotnet_naming_symbols.constants.applicable_kinds = field, local
+dotnet_naming_symbols.constants.applicable_kinds = field
dotnet_naming_symbols.constants.required_modifiers = const
# Locals and parameters are camelCase
@@ -102,9 +121,7 @@ dotnet_naming_rule.locals_should_be_camel_case.severity = warning
# camel_case_style - Define the camelCase style
dotnet_naming_style.camel_case_style.capitalization = camel_case
-dotnet_naming_style.static_field_style.required_prefix = s_
dotnet_naming_symbols.locals_and_parameters.applicable_kinds = parameter, local
-dotnet_naming_symbols.static_fields.required_modifiers = static
# first_upper_style - The first character must start with an upper-case character
dotnet_naming_style.first_upper_style.capitalization = first_word_upper
@@ -152,22 +169,22 @@ dotnet_naming_symbols.other_public_protected_fields_group.applicable_kinds = fie
# StyleCop Field Naming Rules
-# All constant fields must be PascalCase
-dotnet_naming_rule.private_or_internal_field_should_be__fieldname.severity = warning
-dotnet_naming_rule.private_or_internal_field_should_be__fieldname.style = _fieldname
-dotnet_naming_rule.private_or_internal_field_should_be__fieldname.symbols = private_or_internal_field
+# All non-private constant fields must be PascalCase. Private constants are owned by
+# 'private_static_fields_group' below - a field must be covered by exactly one rule, otherwise the
+# same violation is reported once per matching rule.
dotnet_naming_rule.stylecop_constant_fields_must_be_pascal_case_rule.severity = warning
dotnet_naming_rule.stylecop_constant_fields_must_be_pascal_case_rule.style = non_private_static_field_style
dotnet_naming_rule.stylecop_constant_fields_must_be_pascal_case_rule.symbols = stylecop_constant_fields_group
-dotnet_naming_symbols.stylecop_constant_fields_group.applicable_accessibilities = public, internal, protected_internal, protected, private_protected, private
+dotnet_naming_symbols.stylecop_constant_fields_group.applicable_accessibilities = public, internal, protected_internal, protected, private_protected
dotnet_naming_symbols.stylecop_constant_fields_group.applicable_kinds = field
dotnet_naming_symbols.stylecop_constant_fields_group.required_modifiers = const
-# All static readonly fields must be PascalCase
+# All non-private static readonly fields must be PascalCase. Private static readonly fields are
+# owned by 'private_static_fields_group' below (see the note on the constant rule above).
dotnet_naming_rule.stylecop_static_readonly_fields_must_be_pascal_case_rule.severity = warning
dotnet_naming_rule.stylecop_static_readonly_fields_must_be_pascal_case_rule.style = non_private_static_field_style
dotnet_naming_rule.stylecop_static_readonly_fields_must_be_pascal_case_rule.symbols = stylecop_static_readonly_fields_group
-dotnet_naming_symbols.stylecop_static_readonly_fields_group.applicable_accessibilities = public, internal, protected_internal, protected, private_protected, private
+dotnet_naming_symbols.stylecop_static_readonly_fields_group.applicable_accessibilities = public, internal, protected_internal, protected, private_protected
dotnet_naming_symbols.stylecop_static_readonly_fields_group.applicable_kinds = field
dotnet_naming_symbols.stylecop_static_readonly_fields_group.required_modifiers = static, readonly
@@ -178,12 +195,22 @@ dotnet_naming_rule.stylecop_instance_fields_must_be_private_rule.symbols = style
dotnet_naming_symbols.stylecop_fields_must_be_private_group.applicable_accessibilities = public, internal, protected_internal, protected, private_protected
dotnet_naming_symbols.stylecop_fields_must_be_private_group.applicable_kinds = field
-# Private fields must be camelCase
-dotnet_naming_rule.stylecop_private_fields_must_be_camel_case_rule.severity = warning
-dotnet_naming_rule.stylecop_private_fields_must_be_camel_case_rule.style = camel_case_style
-dotnet_naming_rule.stylecop_private_fields_must_be_camel_case_rule.symbols = stylecop_private_fields_group
-dotnet_naming_symbols.stylecop_private_fields_group.applicable_accessibilities = private
-dotnet_naming_symbols.stylecop_private_fields_group.applicable_kinds = field
+# Private static fields are PascalCase: they are type-level state and are never qualified with 'this.'
+dotnet_naming_rule.private_static_fields_must_be_pascal_case_rule.severity = warning
+dotnet_naming_rule.private_static_fields_must_be_pascal_case_rule.style = non_private_static_field_style
+dotnet_naming_rule.private_static_fields_must_be_pascal_case_rule.symbols = private_static_fields_group
+dotnet_naming_symbols.private_static_fields_group.applicable_accessibilities = private
+dotnet_naming_symbols.private_static_fields_group.applicable_kinds = field
+dotnet_naming_symbols.private_static_fields_group.required_modifiers = static
+
+# Private instance fields must be camelCase with a leading underscore: '_name', never 'name'. The
+# prefix keeps field access unambiguous (so the noisy 'this.' qualifier is never needed) and keeps
+# fields distinguishable from locals and parameters.
+dotnet_naming_rule.private_instance_fields_must_be_camel_case_with_underscore_prefix.severity = warning
+dotnet_naming_rule.private_instance_fields_must_be_camel_case_with_underscore_prefix.style = camel_case_underscore_style
+dotnet_naming_rule.private_instance_fields_must_be_camel_case_with_underscore_prefix.symbols = private_instance_fields_group
+dotnet_naming_symbols.private_instance_fields_group.applicable_accessibilities = private
+dotnet_naming_symbols.private_instance_fields_group.applicable_kinds = field
# Local variables must be camelCase
dotnet_naming_rule.stylecop_local_fields_must_be_camel_case_rule.severity = silent
@@ -232,25 +259,14 @@ dotnet_naming_style.type_parameter_style.required_prefix = T
dotnet_naming_symbols.type_parameter_symbol.applicable_accessibilities = *
dotnet_naming_symbols.type_parameter_symbol.applicable_kinds = type_parameter
-# Instance fields are camelCase and start with _
-dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion
-dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
-dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields
-dotnet_naming_rule.instance_fields_should_be_camel_case.severity = suggestion
-dotnet_naming_rule.instance_fields_should_be_camel_case.style = camel_case_underscore_style
-dotnet_naming_rule.instance_fields_should_be_camel_case.symbols = instance_fields
+# Naming style shared by the private-field rules: camelCase with a required '_' prefix.
dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case
dotnet_naming_style.camel_case_underscore_style.required_prefix = _
-dotnet_naming_style.instance_field_style.capitalization = camel_case
-dotnet_naming_style.instance_field_style.required_prefix = _
-dotnet_naming_symbols.instance_fields.applicable_kinds = field
-dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal
-dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
# Local functions are PascalCase
dotnet_naming_rule.local_functions_should_be_pascal_case.severity = warning
-dotnet_naming_rule.local_functions_should_be_pascal_case.style = non_private_static_field_style
-dotnet_naming_rule.local_functions_should_be_pascal_case.symbols = all_members
+dotnet_naming_rule.local_functions_should_be_pascal_case.style = local_function_style
+dotnet_naming_rule.local_functions_should_be_pascal_case.symbols = local_functions
dotnet_naming_style.local_function_style.capitalization = pascal_case
dotnet_naming_symbols.local_functions.applicable_kinds = local_function
@@ -264,12 +280,10 @@ dotnet_style_qualification_for_property = false:silent
dotnet_style_operator_placement_when_wrapping = end_of_line
# Naming styles
-dotnet_naming_rule.interface_should_be_begins_with_i.severity = warning
-dotnet_naming_rule.interface_should_be_begins_with_i.style = prefix_interface_with_i_style
-dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
-dotnet_naming_rule.types_should_be_pascal_case.severity = warning
-dotnet_naming_rule.types_should_be_pascal_case.style = non_private_static_field_style
-dotnet_naming_rule.types_should_be_pascal_case.symbols = types
+# NOTE: a 'types_should_be_pascal_case' rule (symbol group 'types') and an
+# 'interface_should_be_begins_with_i' rule (symbol group 'interface') used to sit here, but neither
+# symbol group was ever defined, so neither rule applied. Types are covered by 'element_rule' and
+# interfaces by 'interface_rule' above.
# By default, name items with PascalCase
dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = warning
@@ -278,7 +292,6 @@ dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_m
# pascal_case_style - Define the PascalCase style
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
-dotnet_naming_symbols.all_members.applicable_kinds = *
# Symbol specifications
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
@@ -286,7 +299,6 @@ dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, meth
dotnet_naming_symbols.non_field_members.required_modifiers = *
# Naming styles
-dotnet_naming_style._fieldname.capitalization = camel_case
dotnet_naming_style.begins_with_i.capitalization = pascal_case
dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
@@ -314,9 +326,11 @@ dotnet_code_quality.prefer_const = true
dotnet_code_quality.prefer_inferred_anonymous_type_member_names = true
dotnet_code_quality.prefer_inferred_tuple_names = true
dotnet_code_quality.prefer_readonly = true
-dotnet_code_quality.require_accessibility_modifiers = true
+# The real modifier policy is 'dotnet_style_require_accessibility_modifiers' (declared under
+# "Modifier preferences" below). The 'require_accessibility_modifiers' and
+# 'require_explicit_visibility' entries that used to live here are not .NET analyzer options:
+# declaring them only pretended to enforce a policy that was never applied, so they were removed.
dotnet_code_quality.require_explicit_type_arguments = true
-dotnet_code_quality.require_explicit_visibility = true
dotnet_code_quality.require_variable_declaration_for_explicit_type = false
dotnet_code_quality_unused_parameters = all:warning
dotnet_enable_roslyn_analyzers = true
@@ -366,12 +380,8 @@ dotnet_style_require_accessibility_modifiers = omit_if_default:warning
# Code-block preferences
csharp_prefer_braces = when_multiline:suggestion
csharp_prefer_simple_using_statement = false:silent
-csharp_prefer_system_threading_lock = true
dotnet_style_prefer_collection_expression = true:suggestion
-# Enable foreach explicit cast preference
-dotnet_style_prefer_foreach_explicit_cast_in_source = when_strongly_typed:warning
-
# Prefer System.Threading.Lock
csharp_prefer_system_threading_lock = true:warning
@@ -503,7 +513,7 @@ dotnet_style_prefer_auto_properties = true:warning
dotnet_style_prefer_compound_assignment = true:warning
dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion
dotnet_style_prefer_conditional_expression_over_return = true:suggestion
-dotnet_style_prefer_foreach_explicit_cast_in_source = when_strongly_typed
+dotnet_style_prefer_foreach_explicit_cast_in_source = when_strongly_typed:warning
dotnet_style_prefer_inferred_anonymous_type_member_names = true:warning
dotnet_style_prefer_inferred_tuple_names = true:warning
dotnet_style_prefer_simplified_boolean_expressions = false:silent
@@ -587,10 +597,14 @@ dotnet_diagnostic.CA1030.severity = suggestion
dotnet_diagnostic.CA1031.severity = error
# Implement standard exception constructors
-dotnet_diagnostic.CA1032.severity = suggestion
+# Raised to warning: the public API surface of exceptions is part of the accessibility policy and
+# must not be invisible to command-line builds.
+dotnet_diagnostic.CA1032.severity = warning
# Interface methods should be callable by child types
-dotnet_diagnostic.CA1033.severity = suggestion
+# Raised to warning: explicit interface implementations that hide the member from derived types are
+# an accessibility problem, not a style preference.
+dotnet_diagnostic.CA1033.severity = warning
# Nested types should not be visible
dotnet_diagnostic.CA1034.severity = error
@@ -599,7 +613,9 @@ dotnet_diagnostic.CA1034.severity = error
dotnet_diagnostic.CA1036.severity = suggestion
# Avoid empty interfaces
-dotnet_diagnostic.CA1040.severity = suggestion
+# Raised to warning: empty interfaces are unenforceable contracts and were previously invisible to
+# command-line builds.
+dotnet_diagnostic.CA1040.severity = warning
# Provide ObsoleteAttribute message
dotnet_diagnostic.CA1041.severity = warning
@@ -794,7 +810,9 @@ dotnet_diagnostic.CA1513.severity = warning
dotnet_diagnostic.CA1514.severity = warning
# Consider making public types internal
-dotnet_diagnostic.CA1515.severity = suggestion
+# Reported as a real build warning (not a suggestion) so accessibility hygiene cannot be ignored:
+# a public type in an application or test assembly should be made internal rather than suppressed.
+dotnet_diagnostic.CA1515.severity = warning
# Naming Rules (CA1700-CA1727 and IDE0130)
# Naming rules support adherence to the naming conventions of the .NET design guidelines
@@ -973,8 +991,9 @@ dotnet_diagnostic.CA1845.severity = error
# Prefer AsSpan over Substring
dotnet_diagnostic.CA1846.severity = error
-dotnet_diagnostic.ignore_internalsvisibleto = true
-dotnet_diagnostic.CA1852.ignore_internalsvisibleto = true
+# CA1852 (seal internal types) is intentionally not suppressed for internal types that are exposed
+# to other assemblies through InternalsVisibleTo: those types must still be sealed. The blanket
+# suppression that used to sit here relied on a malformed key, so it never even applied.
# Unsafe DataSet or DataTable in serializable type can be vulnerable to remote code execution attacks
dotnet_diagnostic.CA2352.severity = error
@@ -1319,8 +1338,9 @@ dotnet_diagnostic.IDE0038.severity = warning
# Use local function instead of lambda
dotnet_diagnostic.IDE0039.severity = suggestion
-# Add accessibility modifiers
-dotnet_diagnostic.IDE0040.severity = error
+# IDE0040 is declared exactly once, in the "Accessibility modifiers" section above. A second entry
+# here used to override that value (later entries win), which made the effective modifier policy
+# ambiguous and let repos believe the rule had been turned off.
# Use is null check
dotnet_diagnostic.IDE0041.severity = suggestion
@@ -1557,8 +1577,9 @@ dotnet_diagnostic.IDE0380.severity = warning
# Remove unnecessary suppression (null-forgiving operator)
dotnet_diagnostic.IDE0370.severity = warning
-# Naming rule violation
-dotnet_diagnostic.IDE1006.severity = silent
+# Naming rule violation - must stay visible: the field-naming policy is only enforced when this
+# diagnostic is reported, because naming rules without their own severity inherit this one.
+dotnet_diagnostic.IDE1006.severity = warning
# Embedded statements must be on their own line
dotnet_diagnostic.IDE2001.severity = warning
@@ -2638,7 +2659,7 @@ trim_trailing_whitespace = false
# If it's a settings, model, dto, etc file, ignore the 'properties' cannot have arrays
# and other annoying rules - the following section is duplicated
-[**/*{ValueObjects,Settings,Options,Model,Models,DTO,Entity,Response,Request}.{cs,vb},]
+[**/*{ValueObjects,Settings,Options,Model,Models,DTO,Entity,Response,Request}{.Nav,}.{cs,vb}]
dotnet_diagnostic.CA1002.severity = none
dotnet_diagnostic.CA1024.severity = none
dotnet_diagnostic.CA1056.severity = none
@@ -2671,17 +2692,14 @@ dotnet_diagnostic.PDS0004.severity = none
[**/Extensions/**.{cs,vb}]
# Files under the Extensions/ namespace-reset convention must not force developers to add pragmas;
-# suppress the namespace-conflict diagnostics that arise from declaring framework-style namespaces.
+# suppress only the namespace-conflict diagnostics that arise from declaring framework-style
+# namespaces. Accessibility/design rules (for example CA1034) are deliberately not suppressed here.
dotnet_diagnostic.IDE0130.severity = none
-dotnet_diagnostic.CA1034.severity = none
dotnet_diagnostic.CA1724.severity = none
dotnet_diagnostic.CS0436.severity = none
dotnet_diagnostic.CS1591.severity = none
dotnet_diagnostic.IDE0005.severity = none
-[**/{Extension,Extensions}.{cs,vb}]
-dotnet_diagnostic.CA1034.severity = none
-
[**/Generated/**/*.{cs,vb}]
generated_code = true
dotnet_diagnostic.CS8602.severity = none
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 5f4c7eb..3a95f9a 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -4,6 +4,13 @@ on:
push:
branches: [main]
+permissions:
+ contents: write
+ # The shared release workflow pushes the same packages to nuget.org and, when
+ # PURVIEW_PUBLISH_GITHUB_PACKAGES=true, to GitHub Packages. A reusable workflow cannot grant
+ # more than its caller, so the permission is declared here.
+ packages: write
+
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
diff --git a/Directory.Packages.props b/Directory.Packages.props
index f716710..2506111 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -8,16 +8,12 @@
5.9.0
5.9.0
- 1.75.0
- 1.1.1
- 5.0.4
- 13.6.1
+ 1.76.0
+ 1.2.0
+ 5.0.5
+ 13.6.3
-
-
-
-
@@ -49,6 +45,6 @@
-
+
diff --git a/global.json b/global.json
index ece4e3d..8b388e3 100644
--- a/global.json
+++ b/global.json
@@ -1,11 +1,13 @@
{
"sdk": {
- "allowPrerelease": false
+ "version": "11.0.100-rc.2.26504.105",
+ "rollForward": "latestMajor",
+ "allowPrerelease": true
},
"msbuild-sdks": {
- "Purview.BuildSdk": "1.0.7"
+ "Purview.BuildSdk": "1.1.0"
},
"test": {
"runner": "Microsoft.Testing.Platform"
}
-}
+}
\ No newline at end of file
diff --git a/package.json b/package.json
index 94defb7..1895230 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "aspirec4",
- "version": "13.6.0-preview.1",
+ "version": "13.6.0-preview.2",
"license": "MIT",
"description": "Aspire LikeC4 Visualization - version manifest for CD pipeline",
"author": {
@@ -32,4 +32,4 @@
"engines": {
"node": ">=22.19.18"
}
-}
+}
\ No newline at end of file
diff --git a/src/src/EntityFrameworkCore.Analyzers/Analysis/EfModelAnalyser.cs b/src/src/EntityFrameworkCore.Analyzers/Analysis/EfModelAnalyser.cs
index fceadbf..11365d9 100644
--- a/src/src/EntityFrameworkCore.Analyzers/Analysis/EfModelAnalyser.cs
+++ b/src/src/EntityFrameworkCore.Analyzers/Analysis/EfModelAnalyser.cs
@@ -223,7 +223,7 @@ HashSet uniqueFromIndexes
|| HasAttribute(property, EfTypes.Attributes.Required)
|| !StoreTypeMap.IsNullable(property.Type);
- var domainType = DomainType(property.Type, complexType: null);
+ var (name, kind) = DomainType(property.Type, complexType: null);
return new ColumnShape
{
@@ -237,8 +237,8 @@ HashSet uniqueFromIndexes
?? GetAttributeNamedString(property, EfTypes.Attributes.Column, "TypeName")
?? StoreTypeMap.ColumnStoreType(property.Type),
ClrTypeName = property.Type.ToDisplayString(),
- DomainTypeName = domainType.Name,
- DomainTypeKind = domainType.Kind,
+ DomainTypeName = name,
+ DomainTypeKind = kind,
IsNullable = !isRequired,
IsUnique =
uniqueFromIndexes.Contains(property.Name) || config?.UniqueProperties.Contains(property.Name) == true,
@@ -294,7 +294,7 @@ static void AddComplexColumns(TableShape table, string prefix, ITypeSymbol compl
continue;
}
- var domainType = DomainType(member.Type, named.Name);
+ var (name, kind) = DomainType(member.Type, named.Name);
table.Columns.Add(
new ColumnShape
@@ -303,8 +303,8 @@ static void AddComplexColumns(TableShape table, string prefix, ITypeSymbol compl
Name = GetAttributeString(member, EfTypes.Attributes.Column, 0) ?? $"{prefix}_{member.Name}",
StoreType = StoreTypeMap.ColumnStoreType(member.Type),
ClrTypeName = member.Type.ToDisplayString(),
- DomainTypeName = domainType.Name,
- DomainTypeKind = domainType.Kind,
+ DomainTypeName = name,
+ DomainTypeKind = kind,
IsNullable = nullable || StoreTypeMap.IsNullable(member.Type),
MaxLength =
GetAttributeInt(member, EfTypes.Attributes.MaxLength, 0)
diff --git a/src/src/EntityFrameworkCore.Analyzers/Helpers/StoreTypeMap.cs b/src/src/EntityFrameworkCore.Analyzers/Helpers/StoreTypeMap.cs
index 75f7f98..6a98c8f 100644
--- a/src/src/EntityFrameworkCore.Analyzers/Helpers/StoreTypeMap.cs
+++ b/src/src/EntityFrameworkCore.Analyzers/Helpers/StoreTypeMap.cs
@@ -145,10 +145,9 @@ static bool IsNamedEnumMember(TypedConstant constant, string member)
}
if (string.Equals(constant.Value.ToString(), member, StringComparison.Ordinal))
- {
return true;
- }
+ // The constant is not the member name, so check whether it is the underlying value of the member.
return constant.Type is INamedTypeSymbol { TypeKind: TypeKind.Enum } enumType
&& enumType
.GetMembers()
diff --git a/src/src/EntityFrameworkCore.ModelDump/EfModelDumpProjector.cs b/src/src/EntityFrameworkCore.ModelDump/EfModelDumpProjector.cs
index baf1ea5..9441719 100644
--- a/src/src/EntityFrameworkCore.ModelDump/EfModelDumpProjector.cs
+++ b/src/src/EntityFrameworkCore.ModelDump/EfModelDumpProjector.cs
@@ -13,7 +13,7 @@ namespace Aspire.Hosting.AspireC4.EntityFrameworkCore.ModelDump;
/// the real model — conventions, value converters and composite foreign keys included. The output is
/// deliberately the diagram's own contract rather than the raw model, so the artifact stays small.
///
-public static class EfModelDumpProjector
+static class EfModelDumpProjector
{
const string UnknownStoreType = "unknown";
@@ -85,7 +85,7 @@ static DumpTable Table(IEntityType entityType)
foreach (var (property, complexType) in Columns(entityType))
{
- var domainType = DomainType(property, complexType);
+ var (name, kind) = DomainType(property, complexType);
columns.Add(
new DumpColumn
@@ -93,8 +93,8 @@ static DumpTable Table(IEntityType entityType)
Name = property.GetColumnName(),
StoreType = ResolveStoreType(ProviderType(property)),
ClrTypeName = property.ClrType.FullName,
- DomainTypeName = domainType.Name,
- DomainTypeKind = domainType.Kind,
+ DomainTypeName = name,
+ DomainTypeKind = kind,
IsNullable = property.IsNullable,
IsPrimaryKey = property.IsPrimaryKey(),
IsUnique = uniqueProperties.Contains(property),
@@ -249,10 +249,10 @@ static string ResolveStoreType(Type type)
}
if (unwrapped == typeof(byte[]))
- {
return "blob";
- }
+ // The AppHost's rule for value objects is to use the provider type, which is what EF stores in the
+ // database. The provider type is already unwrapped, so the nullable check above is only for enums.
return unwrapped.FullName switch
{
"System.Boolean" => "bool",
diff --git a/src/src/EntityFrameworkCore.ModelDump/EfModelDumpRunner.cs b/src/src/EntityFrameworkCore.ModelDump/EfModelDumpRunner.cs
index 2ff542c..a079e03 100644
--- a/src/src/EntityFrameworkCore.ModelDump/EfModelDumpRunner.cs
+++ b/src/src/EntityFrameworkCore.ModelDump/EfModelDumpRunner.cs
@@ -17,7 +17,7 @@ namespace Aspire.Hosting.AspireC4.EntityFrameworkCore.ModelDump;
/// composite foreign keys included. The output directory is the project's obj/, so nothing it
/// writes is deployed or committed.
///
-public static class EfModelDumpRunner
+static class EfModelDumpRunner
{
/// Dumps every context the assembly's design-time factories expose.
/// The built assembly to read contexts from.
diff --git a/src/src/EntityFrameworkCore.ModelDump/Properties/AssemblyInfo.cs b/src/src/EntityFrameworkCore.ModelDump/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..137107f
--- /dev/null
+++ b/src/src/EntityFrameworkCore.ModelDump/Properties/AssemblyInfo.cs
@@ -0,0 +1,3 @@
+using System.Runtime.CompilerServices;
+
+[assembly: InternalsVisibleTo("Aspire.Hosting.AspireC4.EntityFrameworkCore.UnitTests")]
diff --git a/src/src/EntityFrameworkCore/Dbml/DbmlGenerator.cs b/src/src/EntityFrameworkCore/Dbml/DbmlGenerator.cs
index 08af4ee..e37c71f 100644
--- a/src/src/EntityFrameworkCore/Dbml/DbmlGenerator.cs
+++ b/src/src/EntityFrameworkCore/Dbml/DbmlGenerator.cs
@@ -131,7 +131,6 @@ static void WriteColumn(StringBuilder sb, EfColumn column, AspireC4EfDiagramOpti
static void WriteReferences(StringBuilder sb, EfModel model, AspireC4EfDiagramOptions options)
{
Dictionary byName = new(StringComparer.OrdinalIgnoreCase);
-
foreach (var context in model.Contexts)
{
foreach (var table in context.Tables)
diff --git a/src/src/EntityFrameworkCore/EfColumnTypeDisplay.cs b/src/src/EntityFrameworkCore/EfColumnTypeDisplay.cs
index 2cd22df..6fbe5b4 100644
--- a/src/src/EntityFrameworkCore/EfColumnTypeDisplay.cs
+++ b/src/src/EntityFrameworkCore/EfColumnTypeDisplay.cs
@@ -30,10 +30,10 @@ public static string Primary(EfColumn column, AspireC4EfDiagramOptions options)
ArgumentNullException.ThrowIfNull(options);
if (string.IsNullOrEmpty(column.DomainTypeName))
- {
return DatabaseType(column);
- }
+ // The domain type is present, so the headline is either the domain type or the database type,
+ // depending on the configured display order.
return options.DomainTypeDisplay is DomainTypeDisplay.DatabaseFirst or DomainTypeDisplay.DatabaseOnly
? DatabaseType(column)
: column.DomainTypeName;
@@ -56,6 +56,7 @@ public static string Primary(EfColumn column, AspireC4EfDiagramOptions options)
var marker = column.DomainTypeKind == EfDomainTypeKind.Enum;
+#pragma warning disable IDE0072 // Add missing cases
return options.DomainTypeDisplay switch
{
DomainTypeDisplay.DomainTypeFirst => marker ? $"{DatabaseType(column)}, enum" : DatabaseType(column),
@@ -64,6 +65,7 @@ public static string Primary(EfColumn column, AspireC4EfDiagramOptions options)
DomainTypeDisplay.DomainTypeOnly => DatabaseType(column),
_ => null,
};
+#pragma warning restore IDE0072 // Add missing cases
}
/// Composes the inline label, e.g. AssetId (guid) or ActorType (int, enum).
diff --git a/src/src/EntityFrameworkCore/EfModelMetadataReader.cs b/src/src/EntityFrameworkCore/EfModelMetadataReader.cs
index e721b16..32cdbc4 100644
--- a/src/src/EntityFrameworkCore/EfModelMetadataReader.cs
+++ b/src/src/EntityFrameworkCore/EfModelMetadataReader.cs
@@ -380,7 +380,7 @@ static TableShape BuildTable(Type entity, string defaultName, Dictionary uniqueFromIndexes)
{
- var domainType = DomainType(property.PropertyType, complexType: null);
+ var (name, kind) = DomainType(property.PropertyType, complexType: null);
return new ColumnShape
{
@@ -389,8 +389,8 @@ static ColumnShape BuildColumn(PropertyInfo property, HashSet uniqueFrom
StoreType =
GetAttributeNamedString(property, "Column", "TypeName") ?? ColumnStoreType(property.PropertyType),
ClrTypeName = property.PropertyType.FullName,
- DomainTypeName = domainType.Name,
- DomainTypeKind = domainType.Kind,
+ DomainTypeName = name,
+ DomainTypeKind = kind,
IsNullable = IsNullable(property),
IsUnique = uniqueFromIndexes.Contains(property.Name),
MaxLength = GetAttributeInt(property, "MaxLength", 0) ?? GetAttributeInt(property, "StringLength", 0),
@@ -437,7 +437,7 @@ static void AddComplexColumns(TableShape table, string prefix, Type complexType,
continue;
}
- var domainType = DomainType(member.PropertyType, Unwrap(complexType).Name);
+ var (name, kind) = DomainType(member.PropertyType, Unwrap(complexType).Name);
table.Columns.Add(
new ColumnShape
@@ -446,8 +446,8 @@ static void AddComplexColumns(TableShape table, string prefix, Type complexType,
Name = GetAttributeString(member, "Column", 0) ?? $"{prefix}_{member.Name}",
StoreType = ColumnStoreType(member.PropertyType),
ClrTypeName = member.PropertyType.FullName,
- DomainTypeName = domainType.Name,
- DomainTypeKind = domainType.Kind,
+ DomainTypeName = name,
+ DomainTypeKind = kind,
IsNullable = nullable || IsNullable(member),
MaxLength = GetAttributeInt(member, "MaxLength", 0) ?? GetAttributeInt(member, "StringLength", 0),
Comment = GetAttributeString(member, "Comment", 0),
diff --git a/src/src/EntityFrameworkCore/EfRelationshipName.cs b/src/src/EntityFrameworkCore/EfRelationshipName.cs
index 8c47e61..7c805d0 100644
--- a/src/src/EntityFrameworkCore/EfRelationshipName.cs
+++ b/src/src/EntityFrameworkCore/EfRelationshipName.cs
@@ -33,10 +33,9 @@ public static string Label(EfForeignKey foreignKey)
}
if (!string.IsNullOrEmpty(principal))
- {
return $"? → {principal}";
- }
+ // If neither end is named, fall back to the constraint name, and then to the columns.
return !string.IsNullOrEmpty(foreignKey.ConstraintName)
? foreignKey.ConstraintName
: string.Join(", ", foreignKey.Columns);
diff --git a/src/src/SourceGenerators/LikeC4StrictValidatorGenerator.cs b/src/src/SourceGenerators/LikeC4StrictValidatorGenerator.cs
index b7a53d9..1f6c84c 100644
--- a/src/src/SourceGenerators/LikeC4StrictValidatorGenerator.cs
+++ b/src/src/SourceGenerators/LikeC4StrictValidatorGenerator.cs
@@ -41,8 +41,8 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
context.RegisterPostInitializationOutput(ctx =>
{
- foreach (var (HintName, Source) in MarkerAttributeEmitter.EmitMarkAttribute())
- ctx.AddSource(HintName, Source);
+ foreach (var (hintName, source) in MarkerAttributeEmitter.EmitMarkAttribute())
+ ctx.AddSource(hintName, source);
});
// Combine everything and validate.
diff --git a/src/src/TestAppHost/TestAppHost.csproj b/src/src/TestAppHost/TestAppHost.csproj
index 521ce45..c0a3df0 100644
--- a/src/src/TestAppHost/TestAppHost.csproj
+++ b/src/src/TestAppHost/TestAppHost.csproj
@@ -1,4 +1,4 @@
-
+
Exe
true
diff --git a/src/tests/EntityFrameworkCore.Analyzers.UnitTests/AspireC4EfModelGeneratorTests.cs b/src/tests/EntityFrameworkCore.Analyzers.UnitTests/AspireC4EfModelGeneratorTests.cs
index 1485e69..c57d0de 100644
--- a/src/tests/EntityFrameworkCore.Analyzers.UnitTests/AspireC4EfModelGeneratorTests.cs
+++ b/src/tests/EntityFrameworkCore.Analyzers.UnitTests/AspireC4EfModelGeneratorTests.cs
@@ -48,10 +48,10 @@ async Task GenerateDescriptorAsync(string source, CancellationToken canc
public async Task RunGenerator_Always_EmitsTheModelAttributeType(CancellationToken cancellationToken)
{
// Arrange
- const string Source = "namespace Sample;";
+ const string source = "namespace Sample;";
// Act
- using var result = await GenerateAsync(Source, cancellationToken: cancellationToken);
+ using var result = await GenerateAsync(source, cancellationToken: cancellationToken);
// Assert
await Assert.That(result.Generated()).HasGeneratedSyntaxTree("AspireC4EfModelAttribute.g.cs");
@@ -61,10 +61,10 @@ public async Task RunGenerator_Always_EmitsTheModelAttributeType(CancellationTok
public async Task RunGenerator_WithNoDbContext_EmitsNoDescriptor(CancellationToken cancellationToken)
{
// Arrange
- const string Source = "namespace Sample; public class NotAContext { }";
+ const string source = "namespace Sample; public class NotAContext { }";
// Act
- var descriptor = await GenerateDescriptorAsync(Source, cancellationToken);
+ var descriptor = await GenerateDescriptorAsync(source, cancellationToken);
// Assert
await Assert.That(descriptor).IsEmpty();
@@ -404,7 +404,7 @@ CancellationToken cancellationToken
)
{
// Arrange
- const string Source = """
+ const string source = """
using Microsoft.EntityFrameworkCore;
namespace Sample;
@@ -413,7 +413,7 @@ public class EmptyDbContext : DbContext { }
""";
// Act
- using var result = await GenerateAsync(Source, cancellationToken: cancellationToken);
+ using var result = await GenerateAsync(source, cancellationToken: cancellationToken);
// Assert
await Assert.That(result).HasDiagnostic(DiagnosticLibrary.NoEntityTypesDiscovered);
diff --git a/src/tests/EntityFrameworkCore.UnitTests/D2/Generators/D2DSLGeneratorTests.cs b/src/tests/EntityFrameworkCore.UnitTests/D2/Generators/D2DSLGeneratorTests.cs
index 0d39fff..01931d8 100644
--- a/src/tests/EntityFrameworkCore.UnitTests/D2/Generators/D2DSLGeneratorTests.cs
+++ b/src/tests/EntityFrameworkCore.UnitTests/D2/Generators/D2DSLGeneratorTests.cs
@@ -265,10 +265,10 @@ public async Task Generate_NullModel_Throws()
public async Task Sanitize_NameWithSeparators_ProducesBareIdentifier()
{
// Arrange
- const string Value = "Order-Items.2024";
+ const string value = "Order-Items.2024";
// Act
- var result = D2DSLGenerator.Sanitize(Value);
+ var result = D2DSLGenerator.Sanitize(value);
// Assert
await Assert.That(result).IsEqualTo("Order_Items_2024");
@@ -278,10 +278,10 @@ public async Task Sanitize_NameWithSeparators_ProducesBareIdentifier()
public async Task Sanitize_NameStartingWithDigit_IsPrefixed()
{
// Arrange
- const string Value = "2024_orders";
+ const string value = "2024_orders";
// Act
- var result = D2DSLGenerator.Sanitize(Value);
+ var result = D2DSLGenerator.Sanitize(value);
// Assert
await Assert.That(result).IsEqualTo("_2024_orders");
@@ -291,10 +291,10 @@ public async Task Sanitize_NameStartingWithDigit_IsPrefixed()
public async Task Sanitize_ReservedKeyword_IsPrefixed()
{
// Arrange
- const string Value = "style";
+ const string value = "style";
// Act
- var result = D2DSLGenerator.Sanitize(Value);
+ var result = D2DSLGenerator.Sanitize(value);
// Assert
await Assert.That(result).IsEqualTo("_style");