From c771d25cd11a27d268cc7d4fdeeba3c4c4203386 Mon Sep 17 00:00:00 2001 From: Arthur Vickers Date: Sat, 19 Nov 2022 10:27:53 +0000 Subject: [PATCH] Fix passing property and entity type names to ValueGenerated messages (#29609) --- src/EFCore/Diagnostics/CoreLoggerExtensions.cs | 16 ++++++++-------- src/EFCore/Properties/CoreStrings.Designer.cs | 8 ++++---- src/EFCore/Properties/CoreStrings.resx | 10 +++++----- .../ChangeTracking/ChangeTrackerTest.cs | 8 ++++---- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/EFCore/Diagnostics/CoreLoggerExtensions.cs b/src/EFCore/Diagnostics/CoreLoggerExtensions.cs index c1bf623918e..1ba85664bf1 100644 --- a/src/EFCore/Diagnostics/CoreLoggerExtensions.cs +++ b/src/EFCore/Diagnostics/CoreLoggerExtensions.cs @@ -2785,8 +2785,8 @@ public static void ValueGenerated( definition.Log( diagnostics, internalEntityEntry.Context.GetType().ShortDisplayName(), - property.Name, - internalEntityEntry.EntityType.ShortName()); + internalEntityEntry.EntityType.ShortName(), + property.Name); } if (diagnostics.NeedsEventData(definition, out var diagnosticSourceEnabled, out var simpleLogEnabled)) @@ -2808,8 +2808,8 @@ private static string ValueGenerated(EventDefinitionBase definition, EventData p var p = (PropertyValueEventData)payload; return d.GenerateMessage( p.EntityEntry.Context.GetType().ShortDisplayName(), - p.Property.Name, - p.EntityEntry.Metadata.ShortName()); + p.EntityEntry.Metadata.ShortName(), + p.Property.Name); } /// @@ -2837,8 +2837,8 @@ public static void ValueGeneratedSensitive( diagnostics, internalEntityEntry.Context.GetType().ShortDisplayName(), value, - property.Name, - internalEntityEntry.EntityType.ShortName()); + internalEntityEntry.EntityType.ShortName(), + property.Name); } if (diagnostics.NeedsEventData(definition, out var diagnosticSourceEnabled, out var simpleLogEnabled)) @@ -2861,8 +2861,8 @@ private static string ValueGeneratedSensitive(EventDefinitionBase definition, Ev return d.GenerateMessage( p.EntityEntry.Context.GetType().ShortDisplayName(), p.Value, - p.Property.Name, - p.EntityEntry.Metadata.ShortName()); + p.EntityEntry.Metadata.ShortName(), + p.Property.Name); } /// diff --git a/src/EFCore/Properties/CoreStrings.Designer.cs b/src/EFCore/Properties/CoreStrings.Designer.cs index de9d3009197..397607dadaa 100644 --- a/src/EFCore/Properties/CoreStrings.Designer.cs +++ b/src/EFCore/Properties/CoreStrings.Designer.cs @@ -4593,7 +4593,7 @@ public static EventDefinition } /// - /// '{contextType}' generated a temporary value for the property '{2_entityType}.{1_property}'. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see key values. + /// '{contextType}' generated a temporary value for the property '{entityType}.{property}'. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see key values. /// public static EventDefinition LogTempValueGenerated(IDiagnosticsLogger logger) { @@ -4618,7 +4618,7 @@ public static EventDefinition LogTempValueGenerated(IDia } /// - /// '{contextType}' generated temporary value '{keyValue}' for the property '{3_entityType}.{2_property}'. + /// '{contextType}' generated temporary value '{keyValue}' for the property '{entityType}.{property}'. /// public static EventDefinition LogTempValueGeneratedSensitive(IDiagnosticsLogger logger) { @@ -4643,7 +4643,7 @@ public static EventDefinition LogTempValueGenerated(IDia } /// - /// '{contextType}' generated a value for the property '{2_entityType}.{1_property}'. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see key values. + /// '{contextType}' generated a value for the property '{entityType}.{property}'. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see key values. /// public static EventDefinition LogValueGenerated(IDiagnosticsLogger logger) { @@ -4668,7 +4668,7 @@ public static EventDefinition LogValueGenerated(IDiagnos } /// - /// '{contextType}' generated value '{keyValue}' for the property '{3_entityType}.{2_property}'. + /// '{contextType}' generated value '{keyValue}' for the property '{entityType}.{property}'. /// public static EventDefinition LogValueGeneratedSensitive(IDiagnosticsLogger logger) { diff --git a/src/EFCore/Properties/CoreStrings.resx b/src/EFCore/Properties/CoreStrings.resx index 32a8f8bbfab..17727409442 100644 --- a/src/EFCore/Properties/CoreStrings.resx +++ b/src/EFCore/Properties/CoreStrings.resx @@ -965,19 +965,19 @@ Debug CoreEventId.StateChanged string string string EntityState EntityState - '{contextType}' generated a temporary value for the property '{2_entityType}.{1_property}'. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see key values. + '{contextType}' generated a temporary value for the property '{entityType}.{property}'. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see key values. Debug CoreEventId.ValueGenerated string string string - '{contextType}' generated temporary value '{keyValue}' for the property '{3_entityType}.{2_property}'. + '{contextType}' generated temporary value '{keyValue}' for the property '{entityType}.{property}'. Debug CoreEventId.ValueGenerated string object? string string - '{contextType}' generated a value for the property '{2_entityType}.{1_property}'. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see key values. + '{contextType}' generated a value for the property '{entityType}.{property}'. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see key values. Debug CoreEventId.ValueGenerated string string string - '{contextType}' generated value '{keyValue}' for the property '{3_entityType}.{2_property}'. + '{contextType}' generated value '{keyValue}' for the property '{entityType}.{property}'. Debug CoreEventId.ValueGenerated string object? string string @@ -1496,4 +1496,4 @@ Cannot start tracking the entry for entity type '{entityType}' because it was created by a different StateManager instance. - \ No newline at end of file + diff --git a/test/EFCore.Tests/ChangeTracking/ChangeTrackerTest.cs b/test/EFCore.Tests/ChangeTracking/ChangeTrackerTest.cs index 39dca2a350f..33a796c2b6b 100644 --- a/test/EFCore.Tests/ChangeTracking/ChangeTrackerTest.cs +++ b/test/EFCore.Tests/ChangeTracking/ChangeTrackerTest.cs @@ -868,9 +868,9 @@ public async Task Value_generation_is_logged(bool sensitive, bool async, bool te Assert.Equal( sensitive ? CoreResources.LogTempValueGeneratedSensitive(new TestLogger()).GenerateMessage( - nameof(LikeAZooContextSensitive), 1, nameof(Hat.Id), nameof(Hat)) + nameof(LikeAZooContextSensitive), 1, nameof(Hat), nameof(Hat.Id)) : CoreResources.LogTempValueGenerated(new TestLogger()).GenerateMessage( - nameof(LikeAZooContext), nameof(Hat.Id), nameof(Hat)), + nameof(LikeAZooContext), nameof(Hat), nameof(Hat.Id)), message); } else @@ -878,9 +878,9 @@ public async Task Value_generation_is_logged(bool sensitive, bool async, bool te Assert.Equal( sensitive ? CoreResources.LogValueGeneratedSensitive(new TestLogger()).GenerateMessage( - nameof(LikeAZooContextSensitive), 1, nameof(Hat.Id), nameof(Hat)) + nameof(LikeAZooContextSensitive), 1, nameof(Hat), nameof(Hat.Id)) : CoreResources.LogValueGenerated(new TestLogger()).GenerateMessage( - nameof(LikeAZooContext), nameof(Hat.Id), nameof(Hat)), + nameof(LikeAZooContext), nameof(Hat), nameof(Hat.Id)), message); } }