From 4cc3e98e1af3bfb5706d46d7e578fb264d982154 Mon Sep 17 00:00:00 2001 From: Jing Ling Date: Wed, 11 Nov 2026 14:37:24 +0800 Subject: [PATCH] feat: add .NET 11 support, bump version to 2.2.0, unify .editorconfig --- .editorconfig | 363 +++++++++++++++++- .github/actions/setup-env/action.yml | 2 +- .github/workflows/build.yml | 1 + .github/workflows/test.yml | 3 + README.md | 6 +- README.zh-CN.md | 6 +- .../Ling.Audit.Sample.Contracts.csproj | 2 +- .../Ling.Audit.Sample.csproj | 4 +- samples/Ling.Audit.Sample/Program.cs | 2 +- src/Directory.Build.props | 2 +- .../DefaultAuditPrincipalResolver.cs | 2 +- .../Ling.Audit.AspNetCore.csproj | 2 +- .../Attributes/AuditableAttribute.cs | 2 +- .../Attributes/NotAuditedAttribute.cs | 2 +- .../AuditDefaults.cs | 2 +- .../AuditOptions.cs | 2 +- .../DataOperation.cs | 2 +- .../DbContextOptionsBuilderExtensions.cs | 2 +- .../Extensions/ModelBuilderExtensions.cs | 6 +- .../IAuditUserProvider.cs | 2 +- .../IPropertySerializer.cs | 2 +- .../Internal/AuditConventionSetPlugin.cs | 4 +- .../Internal/AuditModelCustomizer.cs | 14 +- .../Internal/AuditSaveChangesInterceptor.cs | 4 +- .../Internal/Constants.cs | 2 +- .../Extensions/AuditOptionsExtension.cs | 6 +- .../Extensions/DbContextExtensions.cs | 4 +- .../Extensions/ReflectionExtensions.cs | 2 +- .../Internal/Models/AuditEntityEntry.cs | 2 +- .../Internal/Models/AuditMetadata.cs | 2 +- .../Internal/Models/AuditPropertyEntry.cs | 2 +- .../Internal/ThrowHelper.cs | 2 +- .../Ling.Audit.EntityFrameworkCore.csproj | 7 +- .../Models/AuditEntityChangeLog.cs | 2 +- .../Models/AuditEventType.cs | 2 +- .../Models/AuditFieldChangeLog.cs | 2 +- src/Ling.Audit.EntityFrameworkCore/README.md | 2 +- .../Analyzers/AuditInterfaceAnalyzer.cs | 2 +- .../Analyzers/AuditKeyTypeAnalyzer.cs | 2 +- .../Analyzers/AuditTypeAnalyzer.cs | 2 +- .../Analyzers/MustNullAttributeAnalyzer.cs | 4 +- .../AuditDefaults.cs | 2 +- .../AuditGenerationContext.cs | 2 +- .../AuditPropertyGenerator.Parser.cs | 2 +- .../AuditInterfaceCodeFixProvider.cs | 4 +- .../CodeFixes/MakeNullableCodeFixProvider.cs | 4 +- .../Helpers/CodeBuilder.cs | 2 +- .../Helpers/EqualityArray.cs | 2 +- .../Helpers/ImmutableHelpers.cs | 2 +- src/Ling.Audit/IHasCreator.cs | 2 +- src/Ling.Audit/MustNullAttribute.cs | 2 +- .../DefaultAuditPrincipalResolverTests.cs | 2 +- .../Ling.Audit.AspNetCore.Tests.csproj | 2 +- ...ing.Audit.EntityFrameworkCore.Tests.csproj | 13 +- .../V2/AuditIntegrationTests.cs | 2 +- .../Ling.Audit.PackageConsumer.csproj | 4 +- .../AuditPropertyGeneratorTests.cs | 6 +- .../Helpers/ImmutableHelpersTests.cs | 2 +- .../Verifiers/CSharpAnalyzerVerifier.cs | 2 +- .../Verifiers/CSharpCodeFixVerifier.cs | 2 +- .../CSharpSourceGeneratorVerifier.cs | 8 +- 61 files changed, 465 insertions(+), 88 deletions(-) diff --git a/.editorconfig b/.editorconfig index 618638d..e32260f 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,14 +1,373 @@ +# Remove the line below if you want to inherit .editorconfig settings from higher directories root = true [*] charset = utf-8 end_of_line = crlf +indent_style = space +indent_size = 4 +tab_width = 4 insert_final_newline = true +trim_trailing_whitespace = true + +# Shell scripts +[*.{yml,yaml}] +end_of_line = lf + +[*.sh] +end_of_line = lf + +[*.{cmd,bat}] +end_of_line = crlf + +# PowerShell scripts, modules, data files, and constrained configuration files +# For non-ASCII text on Windows PowerShell 5.1, override charset with utf-8-bom. +[*.{ps1,psm1,psd1,pssc,psrc}] +indent_style = space +indent_size = 4 +tab_width = 4 + +# Web source files +[*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,css,scss,less,html,htm,vue,svelte}] +indent_style = space +indent_size = 2 +tab_width = 2 + +# Structured data and configuration files +[*.{json,jsonc,json5,yml,yaml,toml}] +indent_style = space +indent_size = 2 +tab_width = 2 + +# Common XML-based files (MSBuild files are configured separately below.) +[*.{xml,config,Config,nuspec,ruleset,runsettings,resx,resw,settings,stylecop,svg,manifest,appxmanifest,vsixmanifest,pubxml,vstemplate,ps1xml,cdxml}] +indent_style = space +indent_size = 2 +tab_width = 2 + +# Resource values can intentionally contain trailing whitespace. +[*.{resx,resw}] +trim_trailing_whitespace = false + +# Markdown preserves trailing spaces because two spaces can represent a hard line break. +[*.{md,mdx}] +indent_style = space +indent_size = 2 +tab_width = 2 +trim_trailing_whitespace = false -[*.{cs,csproj,props,targets,sln}] +# .NET UI markup +[*.{xaml,axaml,razor,cshtml}] indent_style = space indent_size = 4 +tab_width = 4 -[*.{json,yml,yaml,md}] +# MSBuild project files: csproj, fsproj, vbproj, shproj, vcxproj, sqlproj, wapproj, etc. +[*.*proj] indent_style = space indent_size = 2 +tab_width = 2 + +# MSBuild imports, shared-project items, and related build files +[*.{props,targets,tasks,items,projitems,builds}] +indent_style = space +indent_size = 2 +tab_width = 2 + +# XML solution and Visual C++ project companion files +[*.{slnx,vcxproj.filters}] +indent_style = space +indent_size = 2 +tab_width = 2 + +# Legacy solution files are generated by Visual Studio; keep its native formatting. +[*.sln] +indent_style = unset +indent_size = unset +tab_width = unset + +# C# files and scripts +[*.{cs,csx}] + +#### Core EditorConfig Options #### + +# Indentation and spacing +indent_size = 4 +indent_style = space +tab_width = 4 + +#### .NET Code Actions #### + +# Type members +dotnet_hide_advanced_members = false +dotnet_member_insertion_location = with_other_members_of_the_same_kind +dotnet_property_generation_behavior = prefer_auto_properties + +# Symbol search +dotnet_search_reference_assemblies = true + +#### .NET Coding Conventions #### + +# Organize usings +dotnet_separate_import_directive_groups = false +dotnet_sort_system_directives_first = true +file_header_template = unset + +# this. and Me. preferences +dotnet_style_qualification_for_event = false +dotnet_style_qualification_for_field = false +dotnet_style_qualification_for_method = false +dotnet_style_qualification_for_property = false + +# Language keywords vs BCL types preferences +dotnet_style_predefined_type_for_locals_parameters_members = true +dotnet_style_predefined_type_for_member_access = true + +# Parentheses preferences +dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:suggestion +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:suggestion +dotnet_style_parentheses_in_other_operators = never_if_unnecessary:suggestion +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:suggestion + +# Modifier preferences +dotnet_style_require_accessibility_modifiers = for_non_interface_members + +# Expression-level preferences +dotnet_prefer_system_hash_code = true +dotnet_style_coalesce_expression = true +dotnet_style_collection_initializer = true +dotnet_style_explicit_tuple_names = true +dotnet_style_namespace_match_folder = true +dotnet_style_null_propagation = true +dotnet_style_object_initializer = true +dotnet_style_operator_placement_when_wrapping = beginning_of_line +dotnet_style_prefer_auto_properties = true:suggestion +dotnet_style_prefer_collection_expression = when_types_exactly_match +dotnet_style_prefer_compound_assignment = true +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_inferred_anonymous_type_member_names = true +dotnet_style_prefer_inferred_tuple_names = true +dotnet_style_prefer_is_null_check_over_reference_equality_method = true +dotnet_style_prefer_non_hidden_explicit_cast_in_source = true +dotnet_style_prefer_simplified_boolean_expressions = true +dotnet_style_prefer_simplified_interpolation = true + +# Field preferences +dotnet_style_readonly_field = true + +# Parameter preferences +dotnet_code_quality_unused_parameters = all + +# Suppression preferences +dotnet_remove_unnecessary_suppression_exclusions = none + +# New line preferences +dotnet_style_allow_multiple_blank_lines_experimental = false:suggestion +dotnet_style_allow_statement_immediately_after_block_experimental = false + +#### C# Coding Conventions #### + +# var preferences +csharp_style_var_elsewhere = true +csharp_style_var_for_built_in_types = true +csharp_style_var_when_type_is_apparent = true + +# Expression-bodied members +csharp_style_expression_bodied_accessors = true +csharp_style_expression_bodied_constructors = false +csharp_style_expression_bodied_indexers = true +csharp_style_expression_bodied_lambdas = true:suggestion +csharp_style_expression_bodied_local_functions = true:suggestion +csharp_style_expression_bodied_methods = true +csharp_style_expression_bodied_operators = true +csharp_style_expression_bodied_properties = true + +# Pattern matching preferences +csharp_style_pattern_matching_over_as_with_null_check = true +csharp_style_pattern_matching_over_is_with_cast_check = true +csharp_style_prefer_extended_property_pattern = true +csharp_style_prefer_not_pattern = true +csharp_style_prefer_pattern_matching = true:suggestion +csharp_style_prefer_switch_expression = true + +# Null-checking preferences +csharp_style_conditional_delegate_call = true + +# Modifier preferences +csharp_prefer_static_anonymous_function = true +csharp_prefer_static_local_function = true +csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,closed,sealed,override,readonly,unsafe,required,volatile,async +csharp_style_prefer_readonly_struct = true +csharp_style_prefer_readonly_struct_member = true + +# Code-block preferences +csharp_prefer_braces = true +csharp_prefer_simple_using_statement = true +csharp_prefer_system_threading_lock = true +csharp_style_namespace_declarations = file_scoped:suggestion +csharp_style_prefer_labeled_jump_statements = true +csharp_style_prefer_method_group_conversion = true +csharp_style_prefer_primary_constructors = true +csharp_style_prefer_simple_property_accessors = true +csharp_style_prefer_top_level_statements = true + +# Expression-level preferences +csharp_prefer_simple_default_expression = true +csharp_style_deconstructed_variable_declaration = true +csharp_style_implicit_object_creation_when_type_is_apparent = true +csharp_style_inlined_variable_declaration = true +csharp_style_prefer_implicitly_typed_lambda_expression = true +csharp_style_prefer_index_operator = true +csharp_style_prefer_local_over_anonymous_function = true +csharp_style_prefer_null_check_over_type_check = true +csharp_style_prefer_range_operator = true +csharp_style_prefer_tuple_swap = true +csharp_style_prefer_unbound_generic_type_in_nameof = true +csharp_style_prefer_utf8_string_literals = true +csharp_style_throw_expression = true +csharp_style_unused_value_assignment_preference = discard_variable +csharp_style_unused_value_expression_statement_preference = discard_variable + +# 'using' directive preferences +csharp_using_directive_placement = outside_namespace:suggestion + +# New line preferences +csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = false:suggestion +csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = false:suggestion +csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = false:suggestion +csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false +csharp_style_allow_embedded_statements_on_same_line_experimental = true + +#### C# Formatting Rules #### + +# New line preferences +csharp_new_line_before_catch = true +csharp_new_line_before_else = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_open_brace = all +csharp_new_line_between_query_expression_clauses = true + +# Indentation preferences +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_case_contents_when_block = false +csharp_indent_labels = one_less_than_current +csharp_indent_switch_labels = true + +# Space preferences +csharp_space_after_cast = false +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_after_comma = true +csharp_space_after_dot = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_after_semicolon_in_for_statement = true +csharp_space_around_binary_operators = before_and_after +csharp_space_around_declaration_statements = false +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_before_comma = false +csharp_space_before_dot = false +csharp_space_before_open_square_brackets = false +csharp_space_before_semicolon_in_for_statement = false +csharp_space_between_empty_square_brackets = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_method_declaration_name_and_open_parenthesis = false +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_parentheses = false +csharp_space_between_square_brackets = false + +# Wrapping preferences +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = true + +#### Naming styles #### + +# Naming rules + +dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion +dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface +dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i + +dotnet_naming_rule.const_fields_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.const_fields_should_be_pascal_case.symbols = const_fields +dotnet_naming_rule.const_fields_should_be_pascal_case.style = pascal_case + +# Explicit intersection rule ensures non-public const fields are not captured by the private-field rule. +dotnet_naming_rule.private_or_internal_const_fields_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.private_or_internal_const_fields_should_be_pascal_case.symbols = private_or_internal_const_fields +dotnet_naming_rule.private_or_internal_const_fields_should_be_pascal_case.style = pascal_case + +dotnet_naming_rule.private_or_internal_static_fields_should_have_s_prefix.severity = suggestion +dotnet_naming_rule.private_or_internal_static_fields_should_have_s_prefix.symbols = private_or_internal_static_fields +dotnet_naming_rule.private_or_internal_static_fields_should_have_s_prefix.style = static_field + +dotnet_naming_rule.private_or_internal_field_should_be_begins_with__.severity = suggestion +dotnet_naming_rule.private_or_internal_field_should_be_begins_with__.symbols = private_or_internal_field +dotnet_naming_rule.private_or_internal_field_should_be_begins_with__.style = begins_with__ + +dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.types_should_be_pascal_case.symbols = types +dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case + +dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members +dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case + +# Symbol specifications + +dotnet_naming_symbols.interface.applicable_kinds = interface +dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.interface.required_modifiers = + +dotnet_naming_symbols.const_fields.applicable_kinds = field +dotnet_naming_symbols.const_fields.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.const_fields.required_modifiers = const + +dotnet_naming_symbols.private_or_internal_const_fields.applicable_kinds = field +dotnet_naming_symbols.private_or_internal_const_fields.applicable_accessibilities = internal, private, private_protected +dotnet_naming_symbols.private_or_internal_const_fields.required_modifiers = const + +dotnet_naming_symbols.private_or_internal_static_fields.applicable_kinds = field +dotnet_naming_symbols.private_or_internal_static_fields.applicable_accessibilities = internal, private, private_protected +dotnet_naming_symbols.private_or_internal_static_fields.required_modifiers = static + +dotnet_naming_symbols.private_or_internal_field.applicable_kinds = field +dotnet_naming_symbols.private_or_internal_field.applicable_accessibilities = internal, private, private_protected +dotnet_naming_symbols.private_or_internal_field.required_modifiers = + +dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum, delegate +dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.types.required_modifiers = + +dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method +dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.non_field_members.required_modifiers = + +# Naming styles + +dotnet_naming_style.pascal_case.required_prefix = +dotnet_naming_style.pascal_case.required_suffix = +dotnet_naming_style.pascal_case.word_separator = +dotnet_naming_style.pascal_case.capitalization = pascal_case + +dotnet_naming_style.begins_with_i.required_prefix = I +dotnet_naming_style.begins_with_i.required_suffix = +dotnet_naming_style.begins_with_i.word_separator = +dotnet_naming_style.begins_with_i.capitalization = pascal_case + +dotnet_naming_style.begins_with__.required_prefix = _ +dotnet_naming_style.begins_with__.required_suffix = +dotnet_naming_style.begins_with__.word_separator = +dotnet_naming_style.begins_with__.capitalization = camel_case + +dotnet_naming_style.static_field.required_prefix = s_ +dotnet_naming_style.static_field.required_suffix = +dotnet_naming_style.static_field.word_separator = +dotnet_naming_style.static_field.capitalization = camel_case diff --git a/.github/actions/setup-env/action.yml b/.github/actions/setup-env/action.yml index f982081..fd9ed7f 100644 --- a/.github/actions/setup-env/action.yml +++ b/.github/actions/setup-env/action.yml @@ -5,7 +5,7 @@ inputs: dotnet-version: description: One or more .NET SDK channels to install required: false - default: 10.0.x + default: 11.0.x runs: using: composite diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c78c9d8..607adec 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,6 +42,7 @@ jobs: 8.0.x 9.0.x 10.0.x + 11.0.x - name: Restore dependencies run: dotnet restore Ling.Audit.sln diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 45df910..4048878 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -72,9 +72,11 @@ jobs: unzip -Z1 "$efcore" | grep -Fx 'lib/net6.0/Ling.Audit.EntityFrameworkCore.dll' unzip -Z1 "$efcore" | grep -Fx 'lib/net9.0/Ling.Audit.EntityFrameworkCore.dll' unzip -Z1 "$efcore" | grep -Fx 'lib/net10.0/Ling.Audit.EntityFrameworkCore.dll' + unzip -Z1 "$efcore" | grep -Fx 'lib/net11.0/Ling.Audit.EntityFrameworkCore.dll' unzip -Z1 "$aspnetcore" | grep -Fx 'lib/net6.0/Ling.Audit.AspNetCore.dll' unzip -Z1 "$aspnetcore" | grep -Fx 'lib/net9.0/Ling.Audit.AspNetCore.dll' unzip -Z1 "$aspnetcore" | grep -Fx 'lib/net10.0/Ling.Audit.AspNetCore.dll' + unzip -Z1 "$aspnetcore" | grep -Fx 'lib/net11.0/Ling.Audit.AspNetCore.dll' - name: Verify package consumption run: | @@ -105,6 +107,7 @@ jobs: 8.0.x 9.0.x 10.0.x + 11.0.x - name: Restore dependencies run: dotnet restore Ling.Audit.sln diff --git a/README.md b/README.md index ae4a21e..aa4314c 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ English | [简体中文](README.zh-CN.md) | Package | Purpose | Target frameworks | | --- | --- | --- | | [`Ling.Audit`](https://www.nuget.org/packages/Ling.Audit/) [![NuGet](https://img.shields.io/nuget/v/Ling.Audit.svg)](https://www.nuget.org/packages/Ling.Audit/) | Audit contracts, source generator, analyzers, and code fixes. | .NET Standard 2.0 | -| [`Ling.Audit.EntityFrameworkCore`](https://www.nuget.org/packages/Ling.Audit.EntityFrameworkCore/) [![NuGet](https://img.shields.io/nuget/v/Ling.Audit.EntityFrameworkCore.svg)](https://www.nuget.org/packages/Ling.Audit.EntityFrameworkCore/) | Audit-property maintenance, soft deletion, and entity/field change logs. | .NET 6–10 | -| [`Ling.Audit.AspNetCore`](https://www.nuget.org/packages/Ling.Audit.AspNetCore/) [![NuGet](https://img.shields.io/nuget/v/Ling.Audit.AspNetCore.svg)](https://www.nuget.org/packages/Ling.Audit.AspNetCore/) | User, IP address, and client information from the current HTTP request. | .NET 6–10 | +| [`Ling.Audit.EntityFrameworkCore`](https://www.nuget.org/packages/Ling.Audit.EntityFrameworkCore/) [![NuGet](https://img.shields.io/nuget/v/Ling.Audit.EntityFrameworkCore.svg)](https://www.nuget.org/packages/Ling.Audit.EntityFrameworkCore/) | Audit-property maintenance, soft deletion, and entity/field change logs. | .NET 6–11 | +| [`Ling.Audit.AspNetCore`](https://www.nuget.org/packages/Ling.Audit.AspNetCore/) [![NuGet](https://img.shields.io/nuget/v/Ling.Audit.AspNetCore.svg)](https://www.nuget.org/packages/Ling.Audit.AspNetCore/) | User, IP address, and client information from the current HTTP request. | .NET 6–11 | The EF Core and ASP.NET Core packages reference the matching EF Core major version for each target framework. @@ -32,7 +32,7 @@ The EF Core and ASP.NET Core packages reference the matching EF Core major versi Install the core package in the project that owns the entity types: ```shell -dotnet add package Ling.Audit --version 2.1.0 +dotnet add package Ling.Audit --version 2.2.0 ``` Implement the audit interface that matches the entity lifecycle. The type and every containing type must be `partial`: diff --git a/README.zh-CN.md b/README.zh-CN.md index 479ad9e..656c8ab 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -9,8 +9,8 @@ | 包 | 用途 | 目标框架 | | --- | --- | --- | | [`Ling.Audit`](https://www.nuget.org/packages/Ling.Audit/) [![NuGet](https://img.shields.io/nuget/v/Ling.Audit.svg)](https://www.nuget.org/packages/Ling.Audit/) | 审计契约、源代码生成器、Analyzer 和 Code Fix。 | .NET Standard 2.0 | -| [`Ling.Audit.EntityFrameworkCore`](https://www.nuget.org/packages/Ling.Audit.EntityFrameworkCore/) [![NuGet](https://img.shields.io/nuget/v/Ling.Audit.EntityFrameworkCore.svg)](https://www.nuget.org/packages/Ling.Audit.EntityFrameworkCore/) | 审计属性维护、软删除以及实体/字段变更日志。 | .NET 6–10 | -| [`Ling.Audit.AspNetCore`](https://www.nuget.org/packages/Ling.Audit.AspNetCore/) [![NuGet](https://img.shields.io/nuget/v/Ling.Audit.AspNetCore.svg)](https://www.nuget.org/packages/Ling.Audit.AspNetCore/) | 从当前 HTTP 请求获取用户、IP 地址和客户端信息。 | .NET 6–10 | +| [`Ling.Audit.EntityFrameworkCore`](https://www.nuget.org/packages/Ling.Audit.EntityFrameworkCore/) [![NuGet](https://img.shields.io/nuget/v/Ling.Audit.EntityFrameworkCore.svg)](https://www.nuget.org/packages/Ling.Audit.EntityFrameworkCore/) | 审计属性维护、软删除以及实体/字段变更日志。 | .NET 6–11 | +| [`Ling.Audit.AspNetCore`](https://www.nuget.org/packages/Ling.Audit.AspNetCore/) [![NuGet](https://img.shields.io/nuget/v/Ling.Audit.AspNetCore.svg)](https://www.nuget.org/packages/Ling.Audit.AspNetCore/) | 从当前 HTTP 请求获取用户、IP 地址和客户端信息。 | .NET 6–11 | EF Core 与 ASP.NET Core 包会为每个目标框架引用对应主版本的 EF Core。 @@ -32,7 +32,7 @@ EF Core 与 ASP.NET Core 包会为每个目标框架引用对应主版本的 EF 在定义实体的项目中安装核心包: ```shell -dotnet add package Ling.Audit --version 2.1.0 +dotnet add package Ling.Audit --version 2.2.0 ``` 根据实体生命周期实现相应审计接口。实体类型及其所有包含类型都必须是 `partial`: diff --git a/samples/Ling.Audit.Sample.Contracts/Ling.Audit.Sample.Contracts.csproj b/samples/Ling.Audit.Sample.Contracts/Ling.Audit.Sample.Contracts.csproj index 2b2e167..55f7031 100644 --- a/samples/Ling.Audit.Sample.Contracts/Ling.Audit.Sample.Contracts.csproj +++ b/samples/Ling.Audit.Sample.Contracts/Ling.Audit.Sample.Contracts.csproj @@ -1,7 +1,7 @@ - net9.0 + net11.0 enable enable diff --git a/samples/Ling.Audit.Sample/Ling.Audit.Sample.csproj b/samples/Ling.Audit.Sample/Ling.Audit.Sample.csproj index eb7df58..b57f4d5 100644 --- a/samples/Ling.Audit.Sample/Ling.Audit.Sample.csproj +++ b/samples/Ling.Audit.Sample/Ling.Audit.Sample.csproj @@ -1,13 +1,13 @@ - net9.0 + net11.0 enable enable - + diff --git a/samples/Ling.Audit.Sample/Program.cs b/samples/Ling.Audit.Sample/Program.cs index 7833246..869e28a 100644 --- a/samples/Ling.Audit.Sample/Program.cs +++ b/samples/Ling.Audit.Sample/Program.cs @@ -1,7 +1,7 @@ using System.Security.Claims; +using Ling.Audit.AspNetCore; using Ling.Audit.EntityFrameworkCore; using Ling.Audit.Sample.Contracts; -using Ling.Audit.AspNetCore; using Microsoft.EntityFrameworkCore; var builder = WebApplication.CreateBuilder(args); diff --git a/src/Directory.Build.props b/src/Directory.Build.props index b128d60..626fd93 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -8,7 +8,7 @@ - 2.1.0 + 2.2.0 ling921 true diff --git a/src/Ling.Audit.AspNetCore/DefaultAuditPrincipalResolver.cs b/src/Ling.Audit.AspNetCore/DefaultAuditPrincipalResolver.cs index 3def4de..51f5041 100644 --- a/src/Ling.Audit.AspNetCore/DefaultAuditPrincipalResolver.cs +++ b/src/Ling.Audit.AspNetCore/DefaultAuditPrincipalResolver.cs @@ -1,7 +1,7 @@ +using System.Security.Claims; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.Options; -using System.Security.Claims; namespace Ling.Audit.AspNetCore; diff --git a/src/Ling.Audit.AspNetCore/Ling.Audit.AspNetCore.csproj b/src/Ling.Audit.AspNetCore/Ling.Audit.AspNetCore.csproj index 1071f29..94a3580 100644 --- a/src/Ling.Audit.AspNetCore/Ling.Audit.AspNetCore.csproj +++ b/src/Ling.Audit.AspNetCore/Ling.Audit.AspNetCore.csproj @@ -1,7 +1,7 @@ - net6.0;net7.0;net8.0;net9.0;net10.0 + net6.0;net7.0;net8.0;net9.0;net10.0;net11.0 true $(NoWarn);IDE0130 Ling.Audit.AspNetCore diff --git a/src/Ling.Audit.EntityFrameworkCore/Attributes/AuditableAttribute.cs b/src/Ling.Audit.EntityFrameworkCore/Attributes/AuditableAttribute.cs index ea60a6d..7922181 100644 --- a/src/Ling.Audit.EntityFrameworkCore/Attributes/AuditableAttribute.cs +++ b/src/Ling.Audit.EntityFrameworkCore/Attributes/AuditableAttribute.cs @@ -1,4 +1,4 @@ -namespace Ling.Audit.EntityFrameworkCore; +namespace Ling.Audit.EntityFrameworkCore; /// /// Marks an entity class as requiring audit logging. diff --git a/src/Ling.Audit.EntityFrameworkCore/Attributes/NotAuditedAttribute.cs b/src/Ling.Audit.EntityFrameworkCore/Attributes/NotAuditedAttribute.cs index 3c808c2..c16b355 100644 --- a/src/Ling.Audit.EntityFrameworkCore/Attributes/NotAuditedAttribute.cs +++ b/src/Ling.Audit.EntityFrameworkCore/Attributes/NotAuditedAttribute.cs @@ -1,4 +1,4 @@ -namespace Ling.Audit.EntityFrameworkCore; +namespace Ling.Audit.EntityFrameworkCore; /// /// Marks an entity property to be excluded from audit logging, diff --git a/src/Ling.Audit.EntityFrameworkCore/AuditDefaults.cs b/src/Ling.Audit.EntityFrameworkCore/AuditDefaults.cs index 887ba62..9fcb9cc 100644 --- a/src/Ling.Audit.EntityFrameworkCore/AuditDefaults.cs +++ b/src/Ling.Audit.EntityFrameworkCore/AuditDefaults.cs @@ -1,4 +1,4 @@ -namespace Ling.Audit.EntityFrameworkCore; +namespace Ling.Audit.EntityFrameworkCore; /// /// Define the audit configuration items. diff --git a/src/Ling.Audit.EntityFrameworkCore/AuditOptions.cs b/src/Ling.Audit.EntityFrameworkCore/AuditOptions.cs index 24cab70..3d18000 100644 --- a/src/Ling.Audit.EntityFrameworkCore/AuditOptions.cs +++ b/src/Ling.Audit.EntityFrameworkCore/AuditOptions.cs @@ -1,4 +1,4 @@ -using System.Text.Json; +using System.Text.Json; namespace Ling.Audit.EntityFrameworkCore; diff --git a/src/Ling.Audit.EntityFrameworkCore/DataOperation.cs b/src/Ling.Audit.EntityFrameworkCore/DataOperation.cs index a3b72e9..caf79b1 100644 --- a/src/Ling.Audit.EntityFrameworkCore/DataOperation.cs +++ b/src/Ling.Audit.EntityFrameworkCore/DataOperation.cs @@ -1,4 +1,4 @@ -namespace Ling.Audit.EntityFrameworkCore; +namespace Ling.Audit.EntityFrameworkCore; /// /// Specifies fundamental data manipulation operations, typically corresponding to CUD actions. diff --git a/src/Ling.Audit.EntityFrameworkCore/Extensions/DbContextOptionsBuilderExtensions.cs b/src/Ling.Audit.EntityFrameworkCore/Extensions/DbContextOptionsBuilderExtensions.cs index 85d226b..2b583f3 100644 --- a/src/Ling.Audit.EntityFrameworkCore/Extensions/DbContextOptionsBuilderExtensions.cs +++ b/src/Ling.Audit.EntityFrameworkCore/Extensions/DbContextOptionsBuilderExtensions.cs @@ -1,4 +1,4 @@ -using Ling.Audit.EntityFrameworkCore.Internal; +using Ling.Audit.EntityFrameworkCore.Internal; using Ling.Audit.EntityFrameworkCore.Internal.Extensions; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Diagnostics; diff --git a/src/Ling.Audit.EntityFrameworkCore/Extensions/ModelBuilderExtensions.cs b/src/Ling.Audit.EntityFrameworkCore/Extensions/ModelBuilderExtensions.cs index f693cb3..67c7ed6 100644 --- a/src/Ling.Audit.EntityFrameworkCore/Extensions/ModelBuilderExtensions.cs +++ b/src/Ling.Audit.EntityFrameworkCore/Extensions/ModelBuilderExtensions.cs @@ -1,4 +1,6 @@ -using Ling.Audit.EntityFrameworkCore.Internal; +using System.Diagnostics.CodeAnalysis; +using System.Linq.Expressions; +using Ling.Audit.EntityFrameworkCore.Internal; using Ling.Audit.EntityFrameworkCore.Internal.Extensions; using Ling.Audit.EntityFrameworkCore.Internal.Models; using Microsoft.EntityFrameworkCore; @@ -6,8 +8,6 @@ using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.Extensions.Logging; -using System.Diagnostics.CodeAnalysis; -using System.Linq.Expressions; namespace Ling.Audit.EntityFrameworkCore; diff --git a/src/Ling.Audit.EntityFrameworkCore/IAuditUserProvider.cs b/src/Ling.Audit.EntityFrameworkCore/IAuditUserProvider.cs index 8b14ae7..37a305b 100644 --- a/src/Ling.Audit.EntityFrameworkCore/IAuditUserProvider.cs +++ b/src/Ling.Audit.EntityFrameworkCore/IAuditUserProvider.cs @@ -1,4 +1,4 @@ -using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Infrastructure; namespace Ling.Audit.EntityFrameworkCore; diff --git a/src/Ling.Audit.EntityFrameworkCore/IPropertySerializer.cs b/src/Ling.Audit.EntityFrameworkCore/IPropertySerializer.cs index 3a76d4c..72b5c5b 100644 --- a/src/Ling.Audit.EntityFrameworkCore/IPropertySerializer.cs +++ b/src/Ling.Audit.EntityFrameworkCore/IPropertySerializer.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; using System.Text.Json; namespace Ling.Audit.EntityFrameworkCore; diff --git a/src/Ling.Audit.EntityFrameworkCore/Internal/AuditConventionSetPlugin.cs b/src/Ling.Audit.EntityFrameworkCore/Internal/AuditConventionSetPlugin.cs index 6c27a13..3c2548f 100644 --- a/src/Ling.Audit.EntityFrameworkCore/Internal/AuditConventionSetPlugin.cs +++ b/src/Ling.Audit.EntityFrameworkCore/Internal/AuditConventionSetPlugin.cs @@ -1,8 +1,8 @@ -using Microsoft.EntityFrameworkCore.Metadata.Builders; +using System.Reflection; using Ling.Audit.EntityFrameworkCore.Internal.Models; +using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.Metadata.Conventions; using Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure; -using System.Reflection; namespace Ling.Audit.EntityFrameworkCore.Internal; diff --git a/src/Ling.Audit.EntityFrameworkCore/Internal/AuditModelCustomizer.cs b/src/Ling.Audit.EntityFrameworkCore/Internal/AuditModelCustomizer.cs index 762ff3d..6003c01 100644 --- a/src/Ling.Audit.EntityFrameworkCore/Internal/AuditModelCustomizer.cs +++ b/src/Ling.Audit.EntityFrameworkCore/Internal/AuditModelCustomizer.cs @@ -1,4 +1,4 @@ -using Ling.Audit.EntityFrameworkCore.Internal.Extensions; +using Ling.Audit.EntityFrameworkCore.Internal.Extensions; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata.Builders; @@ -58,10 +58,10 @@ public void Configure(EntityTypeBuilder> builder) builder.ToTable(nameof(AuditEntityChangeLog), t => t.HasComment("Table to record changes in entities.")) .HasKey(al => al.Id); #else - builder.ToTable(nameof(AuditEntityChangeLog)) - .HasComment("Table to record changes in entities."); + builder.ToTable(nameof(AuditEntityChangeLog)) + .HasComment("Table to record changes in entities."); - builder.HasKey(al => al.Id); + builder.HasKey(al => al.Id); #endif builder.Property(al => al.Id) @@ -144,10 +144,10 @@ public void Configure(EntityTypeBuilder builder) builder.ToTable(nameof(AuditFieldChangeLog), t => t.HasComment("Table to record changes in entity fields.")) .HasKey(al => al.Id); #else - builder.ToTable(nameof(AuditFieldChangeLog)) - .HasComment("Table to record changes in entity fields."); + builder.ToTable(nameof(AuditFieldChangeLog)) + .HasComment("Table to record changes in entity fields."); - builder.HasKey(al => al.Id); + builder.HasKey(al => al.Id); #endif builder.Property(al => al.Id) diff --git a/src/Ling.Audit.EntityFrameworkCore/Internal/AuditSaveChangesInterceptor.cs b/src/Ling.Audit.EntityFrameworkCore/Internal/AuditSaveChangesInterceptor.cs index 67511a2..8fd360b 100644 --- a/src/Ling.Audit.EntityFrameworkCore/Internal/AuditSaveChangesInterceptor.cs +++ b/src/Ling.Audit.EntityFrameworkCore/Internal/AuditSaveChangesInterceptor.cs @@ -1,3 +1,5 @@ +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; using Ling.Audit.EntityFrameworkCore.Internal.Extensions; using Ling.Audit.EntityFrameworkCore.Internal.Models; using Microsoft.EntityFrameworkCore; @@ -5,8 +7,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.Extensions.Logging; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; namespace Ling.Audit.EntityFrameworkCore.Internal; diff --git a/src/Ling.Audit.EntityFrameworkCore/Internal/Constants.cs b/src/Ling.Audit.EntityFrameworkCore/Internal/Constants.cs index 3f29180..056f5b1 100644 --- a/src/Ling.Audit.EntityFrameworkCore/Internal/Constants.cs +++ b/src/Ling.Audit.EntityFrameworkCore/Internal/Constants.cs @@ -1,4 +1,4 @@ -using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Configuration; namespace Ling.Audit.EntityFrameworkCore.Internal; diff --git a/src/Ling.Audit.EntityFrameworkCore/Internal/Extensions/AuditOptionsExtension.cs b/src/Ling.Audit.EntityFrameworkCore/Internal/Extensions/AuditOptionsExtension.cs index 7c57114..d5f85f7 100644 --- a/src/Ling.Audit.EntityFrameworkCore/Internal/Extensions/AuditOptionsExtension.cs +++ b/src/Ling.Audit.EntityFrameworkCore/Internal/Extensions/AuditOptionsExtension.cs @@ -1,10 +1,10 @@ -using Microsoft.EntityFrameworkCore.Infrastructure; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; -using System.Diagnostics.CodeAnalysis; -using System.Text.Json; namespace Ling.Audit.EntityFrameworkCore.Internal.Extensions; diff --git a/src/Ling.Audit.EntityFrameworkCore/Internal/Extensions/DbContextExtensions.cs b/src/Ling.Audit.EntityFrameworkCore/Internal/Extensions/DbContextExtensions.cs index 2d89381..c0e6c46 100644 --- a/src/Ling.Audit.EntityFrameworkCore/Internal/Extensions/DbContextExtensions.cs +++ b/src/Ling.Audit.EntityFrameworkCore/Internal/Extensions/DbContextExtensions.cs @@ -1,9 +1,9 @@ -using Microsoft.EntityFrameworkCore; +using System.Text.Json; +using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.ChangeTracking; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.Extensions.Options; -using System.Text.Json; namespace Ling.Audit.EntityFrameworkCore.Internal.Extensions; diff --git a/src/Ling.Audit.EntityFrameworkCore/Internal/Extensions/ReflectionExtensions.cs b/src/Ling.Audit.EntityFrameworkCore/Internal/Extensions/ReflectionExtensions.cs index 69fffbf..d268ccf 100644 --- a/src/Ling.Audit.EntityFrameworkCore/Internal/Extensions/ReflectionExtensions.cs +++ b/src/Ling.Audit.EntityFrameworkCore/Internal/Extensions/ReflectionExtensions.cs @@ -1,4 +1,4 @@ -using System.Text; +using System.Text; namespace Ling.Audit.EntityFrameworkCore.Internal.Extensions; diff --git a/src/Ling.Audit.EntityFrameworkCore/Internal/Models/AuditEntityEntry.cs b/src/Ling.Audit.EntityFrameworkCore/Internal/Models/AuditEntityEntry.cs index 99d1c53..5614ff9 100644 --- a/src/Ling.Audit.EntityFrameworkCore/Internal/Models/AuditEntityEntry.cs +++ b/src/Ling.Audit.EntityFrameworkCore/Internal/Models/AuditEntityEntry.cs @@ -1,4 +1,4 @@ -using Ling.Audit.EntityFrameworkCore.Internal.Extensions; +using Ling.Audit.EntityFrameworkCore.Internal.Extensions; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.ChangeTracking; diff --git a/src/Ling.Audit.EntityFrameworkCore/Internal/Models/AuditMetadata.cs b/src/Ling.Audit.EntityFrameworkCore/Internal/Models/AuditMetadata.cs index 31cf90a..21dde57 100644 --- a/src/Ling.Audit.EntityFrameworkCore/Internal/Models/AuditMetadata.cs +++ b/src/Ling.Audit.EntityFrameworkCore/Internal/Models/AuditMetadata.cs @@ -1,4 +1,4 @@ -namespace Ling.Audit.EntityFrameworkCore.Internal.Models; +namespace Ling.Audit.EntityFrameworkCore.Internal.Models; /// /// Represents audit metadata for an entity type. diff --git a/src/Ling.Audit.EntityFrameworkCore/Internal/Models/AuditPropertyEntry.cs b/src/Ling.Audit.EntityFrameworkCore/Internal/Models/AuditPropertyEntry.cs index 5ab33e6..d054497 100644 --- a/src/Ling.Audit.EntityFrameworkCore/Internal/Models/AuditPropertyEntry.cs +++ b/src/Ling.Audit.EntityFrameworkCore/Internal/Models/AuditPropertyEntry.cs @@ -1,4 +1,4 @@ -namespace Ling.Audit.EntityFrameworkCore.Internal.Models; +namespace Ling.Audit.EntityFrameworkCore.Internal.Models; /// /// Represents temporary tracking information for a property change during auditing. diff --git a/src/Ling.Audit.EntityFrameworkCore/Internal/ThrowHelper.cs b/src/Ling.Audit.EntityFrameworkCore/Internal/ThrowHelper.cs index 864da2a..b5ab6f4 100644 --- a/src/Ling.Audit.EntityFrameworkCore/Internal/ThrowHelper.cs +++ b/src/Ling.Audit.EntityFrameworkCore/Internal/ThrowHelper.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; namespace Ling.Audit.EntityFrameworkCore.Internal; diff --git a/src/Ling.Audit.EntityFrameworkCore/Ling.Audit.EntityFrameworkCore.csproj b/src/Ling.Audit.EntityFrameworkCore/Ling.Audit.EntityFrameworkCore.csproj index 10a245f..812f708 100644 --- a/src/Ling.Audit.EntityFrameworkCore/Ling.Audit.EntityFrameworkCore.csproj +++ b/src/Ling.Audit.EntityFrameworkCore/Ling.Audit.EntityFrameworkCore.csproj @@ -1,7 +1,7 @@ - net6.0;net7.0;net8.0;net9.0;net10.0 + net6.0;net7.0;net8.0;net9.0;net10.0;net11.0 true $(NoWarn);IDE0130 Ling.Audit.EntityFrameworkCore @@ -48,6 +48,11 @@ + + + + + <_Parameter1>Ling.Audit.AspNetCore diff --git a/src/Ling.Audit.EntityFrameworkCore/Models/AuditEntityChangeLog.cs b/src/Ling.Audit.EntityFrameworkCore/Models/AuditEntityChangeLog.cs index c1da31e..4bf256e 100644 --- a/src/Ling.Audit.EntityFrameworkCore/Models/AuditEntityChangeLog.cs +++ b/src/Ling.Audit.EntityFrameworkCore/Models/AuditEntityChangeLog.cs @@ -1,5 +1,5 @@ -using Microsoft.EntityFrameworkCore.ChangeTracking; using System.Diagnostics; +using Microsoft.EntityFrameworkCore.ChangeTracking; namespace Ling.Audit.EntityFrameworkCore; diff --git a/src/Ling.Audit.EntityFrameworkCore/Models/AuditEventType.cs b/src/Ling.Audit.EntityFrameworkCore/Models/AuditEventType.cs index 8c38808..9f29635 100644 --- a/src/Ling.Audit.EntityFrameworkCore/Models/AuditEventType.cs +++ b/src/Ling.Audit.EntityFrameworkCore/Models/AuditEventType.cs @@ -1,4 +1,4 @@ -namespace Ling.Audit.EntityFrameworkCore; +namespace Ling.Audit.EntityFrameworkCore; /// /// Enum that specifies audit event type. diff --git a/src/Ling.Audit.EntityFrameworkCore/Models/AuditFieldChangeLog.cs b/src/Ling.Audit.EntityFrameworkCore/Models/AuditFieldChangeLog.cs index 0b69277..09d1adc 100644 --- a/src/Ling.Audit.EntityFrameworkCore/Models/AuditFieldChangeLog.cs +++ b/src/Ling.Audit.EntityFrameworkCore/Models/AuditFieldChangeLog.cs @@ -1,4 +1,4 @@ -using System.Diagnostics; +using System.Diagnostics; namespace Ling.Audit.EntityFrameworkCore; diff --git a/src/Ling.Audit.EntityFrameworkCore/README.md b/src/Ling.Audit.EntityFrameworkCore/README.md index 21b0ccd..7feb58c 100644 --- a/src/Ling.Audit.EntityFrameworkCore/README.md +++ b/src/Ling.Audit.EntityFrameworkCore/README.md @@ -10,7 +10,7 @@ This package applies audit metadata during `SaveChanges`, maintains creation, mo dotnet add package Ling.Audit.EntityFrameworkCore ``` -The package targets .NET 6.0 through .NET 10.0 and uses the matching EF Core major version. +The package targets .NET 6.0 through .NET 11.0 and uses the matching EF Core major version. ## Quick start diff --git a/src/Ling.Audit.SourceGenerators/Analyzers/AuditInterfaceAnalyzer.cs b/src/Ling.Audit.SourceGenerators/Analyzers/AuditInterfaceAnalyzer.cs index 6282067..d28c7d8 100644 --- a/src/Ling.Audit.SourceGenerators/Analyzers/AuditInterfaceAnalyzer.cs +++ b/src/Ling.Audit.SourceGenerators/Analyzers/AuditInterfaceAnalyzer.cs @@ -1,10 +1,10 @@ +using System.Collections.Immutable; using Ling.Audit.SourceGenerators.Diagnostics; using Ling.Audit.SourceGenerators.Helpers; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; -using System.Collections.Immutable; namespace Ling.Audit.SourceGenerators.Analyzers; diff --git a/src/Ling.Audit.SourceGenerators/Analyzers/AuditKeyTypeAnalyzer.cs b/src/Ling.Audit.SourceGenerators/Analyzers/AuditKeyTypeAnalyzer.cs index 4e0f795..1fb14c0 100644 --- a/src/Ling.Audit.SourceGenerators/Analyzers/AuditKeyTypeAnalyzer.cs +++ b/src/Ling.Audit.SourceGenerators/Analyzers/AuditKeyTypeAnalyzer.cs @@ -1,10 +1,10 @@ +using System.Collections.Immutable; using Ling.Audit.SourceGenerators.Diagnostics; using Ling.Audit.SourceGenerators.Helpers; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; -using System.Collections.Immutable; namespace Ling.Audit.SourceGenerators.Analyzers; diff --git a/src/Ling.Audit.SourceGenerators/Analyzers/AuditTypeAnalyzer.cs b/src/Ling.Audit.SourceGenerators/Analyzers/AuditTypeAnalyzer.cs index f3ddefa..7a93bad 100644 --- a/src/Ling.Audit.SourceGenerators/Analyzers/AuditTypeAnalyzer.cs +++ b/src/Ling.Audit.SourceGenerators/Analyzers/AuditTypeAnalyzer.cs @@ -1,9 +1,9 @@ +using System.Collections.Immutable; using Ling.Audit.SourceGenerators.Diagnostics; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; -using System.Collections.Immutable; namespace Ling.Audit.SourceGenerators.Analyzers; diff --git a/src/Ling.Audit.SourceGenerators/Analyzers/MustNullAttributeAnalyzer.cs b/src/Ling.Audit.SourceGenerators/Analyzers/MustNullAttributeAnalyzer.cs index 9383ee1..36f09c6 100644 --- a/src/Ling.Audit.SourceGenerators/Analyzers/MustNullAttributeAnalyzer.cs +++ b/src/Ling.Audit.SourceGenerators/Analyzers/MustNullAttributeAnalyzer.cs @@ -1,10 +1,10 @@ +using System.Collections.Immutable; using Ling.Audit.SourceGenerators.Diagnostics; using Ling.Audit.SourceGenerators.Helpers; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; -using System.Collections.Immutable; namespace Ling.Audit.SourceGenerators.Analyzers; @@ -253,7 +253,7 @@ private static void CheckGenericMethodSymbol(SyntaxNodeAnalysisContext context, if (argument is not ITypeParameterSymbol && !argument.CanAssignNull()) { var diagnostic = Diagnostic.Create( - argumentSyntax is TypeSyntax + argumentSyntax is TypeSyntax ? DiagnosticDescriptors.TypeParameterMustBeNullable : DiagnosticDescriptors.ParameterTypeMustBeNullable, argumentSyntax.GetLocation(), diff --git a/src/Ling.Audit.SourceGenerators/AuditDefaults.cs b/src/Ling.Audit.SourceGenerators/AuditDefaults.cs index 8e6c641..a0b997a 100644 --- a/src/Ling.Audit.SourceGenerators/AuditDefaults.cs +++ b/src/Ling.Audit.SourceGenerators/AuditDefaults.cs @@ -1,4 +1,4 @@ -namespace Ling.Audit.SourceGenerators; +namespace Ling.Audit.SourceGenerators; internal static class AuditDefaults { diff --git a/src/Ling.Audit.SourceGenerators/AuditGenerationContext.cs b/src/Ling.Audit.SourceGenerators/AuditGenerationContext.cs index 479ff5e..53ed46e 100644 --- a/src/Ling.Audit.SourceGenerators/AuditGenerationContext.cs +++ b/src/Ling.Audit.SourceGenerators/AuditGenerationContext.cs @@ -1,4 +1,4 @@ -using Ling.Audit.SourceGenerators.Helpers; +using Ling.Audit.SourceGenerators.Helpers; using Microsoft.CodeAnalysis.CSharp.Syntax; namespace Ling.Audit.SourceGenerators; diff --git a/src/Ling.Audit.SourceGenerators/AuditPropertyGenerator.Parser.cs b/src/Ling.Audit.SourceGenerators/AuditPropertyGenerator.Parser.cs index 958f994..47d7fc9 100644 --- a/src/Ling.Audit.SourceGenerators/AuditPropertyGenerator.Parser.cs +++ b/src/Ling.Audit.SourceGenerators/AuditPropertyGenerator.Parser.cs @@ -1,8 +1,8 @@ +using System.Text; using Ling.Audit.SourceGenerators.Helpers; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; -using System.Text; namespace Ling.Audit.SourceGenerators; diff --git a/src/Ling.Audit.SourceGenerators/CodeFixes/AuditInterfaceCodeFixProvider.cs b/src/Ling.Audit.SourceGenerators/CodeFixes/AuditInterfaceCodeFixProvider.cs index 7350d89..0404bf6 100644 --- a/src/Ling.Audit.SourceGenerators/CodeFixes/AuditInterfaceCodeFixProvider.cs +++ b/src/Ling.Audit.SourceGenerators/CodeFixes/AuditInterfaceCodeFixProvider.cs @@ -1,11 +1,11 @@ +using System.Collections.Immutable; +using System.Composition; using Ling.Audit.SourceGenerators.Diagnostics; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CodeActions; using Microsoft.CodeAnalysis.CodeFixes; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; -using System.Collections.Immutable; -using System.Composition; namespace Ling.Audit.SourceGenerators.CodeFixes; diff --git a/src/Ling.Audit.SourceGenerators/CodeFixes/MakeNullableCodeFixProvider.cs b/src/Ling.Audit.SourceGenerators/CodeFixes/MakeNullableCodeFixProvider.cs index 97c7363..f1edc56 100644 --- a/src/Ling.Audit.SourceGenerators/CodeFixes/MakeNullableCodeFixProvider.cs +++ b/src/Ling.Audit.SourceGenerators/CodeFixes/MakeNullableCodeFixProvider.cs @@ -1,11 +1,11 @@ +using System.Collections.Immutable; +using System.Composition; using Ling.Audit.SourceGenerators.Diagnostics; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CodeActions; using Microsoft.CodeAnalysis.CodeFixes; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; -using System.Collections.Immutable; -using System.Composition; namespace Ling.Audit.SourceGenerators.CodeFixes; diff --git a/src/Ling.Audit.SourceGenerators/Helpers/CodeBuilder.cs b/src/Ling.Audit.SourceGenerators/Helpers/CodeBuilder.cs index 8eb05a5..451eadc 100644 --- a/src/Ling.Audit.SourceGenerators/Helpers/CodeBuilder.cs +++ b/src/Ling.Audit.SourceGenerators/Helpers/CodeBuilder.cs @@ -1,4 +1,4 @@ -using System.Diagnostics; +using System.Diagnostics; using System.Text; namespace Ling.Audit.SourceGenerators.Helpers; diff --git a/src/Ling.Audit.SourceGenerators/Helpers/EqualityArray.cs b/src/Ling.Audit.SourceGenerators/Helpers/EqualityArray.cs index ac1959f..49a8cf6 100644 --- a/src/Ling.Audit.SourceGenerators/Helpers/EqualityArray.cs +++ b/src/Ling.Audit.SourceGenerators/Helpers/EqualityArray.cs @@ -1,4 +1,4 @@ -using System.Collections; +using System.Collections; namespace Ling.Audit.SourceGenerators.Helpers; diff --git a/src/Ling.Audit.SourceGenerators/Helpers/ImmutableHelpers.cs b/src/Ling.Audit.SourceGenerators/Helpers/ImmutableHelpers.cs index 2f5f9df..31cc5ed 100644 --- a/src/Ling.Audit.SourceGenerators/Helpers/ImmutableHelpers.cs +++ b/src/Ling.Audit.SourceGenerators/Helpers/ImmutableHelpers.cs @@ -1,4 +1,4 @@ -using System.Collections.Immutable; +using System.Collections.Immutable; namespace Ling.Audit.SourceGenerators.Helpers; diff --git a/src/Ling.Audit/IHasCreator.cs b/src/Ling.Audit/IHasCreator.cs index 9895d93..175a044 100644 --- a/src/Ling.Audit/IHasCreator.cs +++ b/src/Ling.Audit/IHasCreator.cs @@ -1,4 +1,4 @@ -namespace Ling.Audit; +namespace Ling.Audit; /// /// Defines an object that tracks creator information. diff --git a/src/Ling.Audit/MustNullAttribute.cs b/src/Ling.Audit/MustNullAttribute.cs index 9cf0cb4..12137bb 100644 --- a/src/Ling.Audit/MustNullAttribute.cs +++ b/src/Ling.Audit/MustNullAttribute.cs @@ -1,4 +1,4 @@ -namespace Ling.Audit; +namespace Ling.Audit; /// /// Marks a generic parameter as nullable. diff --git a/tests/Ling.Audit.AspNetCore.Tests/DefaultAuditPrincipalResolverTests.cs b/tests/Ling.Audit.AspNetCore.Tests/DefaultAuditPrincipalResolverTests.cs index 1419596..8472363 100644 --- a/tests/Ling.Audit.AspNetCore.Tests/DefaultAuditPrincipalResolverTests.cs +++ b/tests/Ling.Audit.AspNetCore.Tests/DefaultAuditPrincipalResolverTests.cs @@ -1,7 +1,7 @@ +using System.Security.Claims; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.Options; -using System.Security.Claims; namespace Ling.Audit.AspNetCore.Tests; diff --git a/tests/Ling.Audit.AspNetCore.Tests/Ling.Audit.AspNetCore.Tests.csproj b/tests/Ling.Audit.AspNetCore.Tests/Ling.Audit.AspNetCore.Tests.csproj index 0adee52..301bb8b 100644 --- a/tests/Ling.Audit.AspNetCore.Tests/Ling.Audit.AspNetCore.Tests.csproj +++ b/tests/Ling.Audit.AspNetCore.Tests/Ling.Audit.AspNetCore.Tests.csproj @@ -1,7 +1,7 @@ - net6.0;net7.0;net8.0;net9.0;net10.0 + net6.0;net7.0;net8.0;net9.0;net10.0;net11.0 enable enable false diff --git a/tests/Ling.Audit.EntityFrameworkCore.Tests1/Ling.Audit.EntityFrameworkCore.Tests.csproj b/tests/Ling.Audit.EntityFrameworkCore.Tests1/Ling.Audit.EntityFrameworkCore.Tests.csproj index 9fc5428..58b3b20 100644 --- a/tests/Ling.Audit.EntityFrameworkCore.Tests1/Ling.Audit.EntityFrameworkCore.Tests.csproj +++ b/tests/Ling.Audit.EntityFrameworkCore.Tests1/Ling.Audit.EntityFrameworkCore.Tests.csproj @@ -1,7 +1,7 @@  - net6.0;net7.0;net8.0;net9.0;net10.0 + net6.0;net7.0;net8.0;net9.0;net10.0;net11.0 enable enable false @@ -23,7 +23,13 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + + + + + + + @@ -45,6 +51,9 @@ + + + diff --git a/tests/Ling.Audit.EntityFrameworkCore.Tests1/V2/AuditIntegrationTests.cs b/tests/Ling.Audit.EntityFrameworkCore.Tests1/V2/AuditIntegrationTests.cs index 9ec9b9b..40d527e 100644 --- a/tests/Ling.Audit.EntityFrameworkCore.Tests1/V2/AuditIntegrationTests.cs +++ b/tests/Ling.Audit.EntityFrameworkCore.Tests1/V2/AuditIntegrationTests.cs @@ -1,8 +1,8 @@ +using System.Text.Json; using Ling.Audit; using Microsoft.Data.Sqlite; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; -using System.Text.Json; namespace Ling.Audit.EntityFrameworkCore.Tests; diff --git a/tests/Ling.Audit.PackageConsumer/Ling.Audit.PackageConsumer.csproj b/tests/Ling.Audit.PackageConsumer/Ling.Audit.PackageConsumer.csproj index bf00f2f..056bd7a 100644 --- a/tests/Ling.Audit.PackageConsumer/Ling.Audit.PackageConsumer.csproj +++ b/tests/Ling.Audit.PackageConsumer/Ling.Audit.PackageConsumer.csproj @@ -2,14 +2,14 @@ Exe - net10.0 + net11.0 enable enable ..\..\artifacts\package-consumer-final - + diff --git a/tests/Ling.Audit.SourceGenerators.Tests/AuditPropertyGeneratorTests.cs b/tests/Ling.Audit.SourceGenerators.Tests/AuditPropertyGeneratorTests.cs index 9fd7d3f..c39ce5c 100644 --- a/tests/Ling.Audit.SourceGenerators.Tests/AuditPropertyGeneratorTests.cs +++ b/tests/Ling.Audit.SourceGenerators.Tests/AuditPropertyGeneratorTests.cs @@ -24,7 +24,7 @@ public partial class GlobalEntity : IHasCreator, IHasCreationTime #pragma warning disable #nullable enable annotations - [global::System.CodeDom.Compiler.GeneratedCode("Ling.Audit.SourceGenerators", "2.1.0")] + [global::System.CodeDom.Compiler.GeneratedCode("Ling.Audit.SourceGenerators", "2.2.0")] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class GlobalEntity { @@ -61,7 +61,7 @@ public partial class SecondEntity : ISoftDelete { } namespace Test { - [global::System.CodeDom.Compiler.GeneratedCode("Ling.Audit.SourceGenerators", "2.1.0")] + [global::System.CodeDom.Compiler.GeneratedCode("Ling.Audit.SourceGenerators", "2.2.0")] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class FirstEntity { @@ -80,7 +80,7 @@ partial class FirstEntity namespace Test { - [global::System.CodeDom.Compiler.GeneratedCode("Ling.Audit.SourceGenerators", "2.1.0")] + [global::System.CodeDom.Compiler.GeneratedCode("Ling.Audit.SourceGenerators", "2.2.0")] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] partial class SecondEntity { diff --git a/tests/Ling.Audit.SourceGenerators.Tests/Helpers/ImmutableHelpersTests.cs b/tests/Ling.Audit.SourceGenerators.Tests/Helpers/ImmutableHelpersTests.cs index 3ce6c06..7ba805a 100644 --- a/tests/Ling.Audit.SourceGenerators.Tests/Helpers/ImmutableHelpersTests.cs +++ b/tests/Ling.Audit.SourceGenerators.Tests/Helpers/ImmutableHelpersTests.cs @@ -1,5 +1,5 @@ -using Ling.Audit.SourceGenerators.Helpers; using System.Collections.Immutable; +using Ling.Audit.SourceGenerators.Helpers; using Xunit; namespace Ling.Audit.SourceGenerators.Tests.Helpers; diff --git a/tests/Ling.Audit.SourceGenerators.Tests/Verifiers/CSharpAnalyzerVerifier.cs b/tests/Ling.Audit.SourceGenerators.Tests/Verifiers/CSharpAnalyzerVerifier.cs index cb4d6f3..48b7dfb 100644 --- a/tests/Ling.Audit.SourceGenerators.Tests/Verifiers/CSharpAnalyzerVerifier.cs +++ b/tests/Ling.Audit.SourceGenerators.Tests/Verifiers/CSharpAnalyzerVerifier.cs @@ -1,8 +1,8 @@ +using System.Collections.Immutable; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Testing; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Testing; -using System.Collections.Immutable; namespace Ling.Audit.SourceGenerators.Tests.Verifiers; diff --git a/tests/Ling.Audit.SourceGenerators.Tests/Verifiers/CSharpCodeFixVerifier.cs b/tests/Ling.Audit.SourceGenerators.Tests/Verifiers/CSharpCodeFixVerifier.cs index 95bc313..50045ae 100644 --- a/tests/Ling.Audit.SourceGenerators.Tests/Verifiers/CSharpCodeFixVerifier.cs +++ b/tests/Ling.Audit.SourceGenerators.Tests/Verifiers/CSharpCodeFixVerifier.cs @@ -1,9 +1,9 @@ +using System.Collections.Immutable; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CodeFixes; using Microsoft.CodeAnalysis.CSharp.Testing; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Testing; -using System.Collections.Immutable; namespace Ling.Audit.SourceGenerators.Tests.Verifiers; diff --git a/tests/Ling.Audit.SourceGenerators.Tests/Verifiers/CSharpSourceGeneratorVerifier.cs b/tests/Ling.Audit.SourceGenerators.Tests/Verifiers/CSharpSourceGeneratorVerifier.cs index 3f808d7..013d78f 100644 --- a/tests/Ling.Audit.SourceGenerators.Tests/Verifiers/CSharpSourceGeneratorVerifier.cs +++ b/tests/Ling.Audit.SourceGenerators.Tests/Verifiers/CSharpSourceGeneratorVerifier.cs @@ -1,10 +1,10 @@ -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp.Testing; -using Microsoft.CodeAnalysis.Testing; -using Microsoft.CodeAnalysis.Text; using System.Collections.Immutable; using System.Text; using System.Text.RegularExpressions; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Testing; +using Microsoft.CodeAnalysis.Testing; +using Microsoft.CodeAnalysis.Text; namespace Ling.Audit.SourceGenerators.Tests.Verifiers;