Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix passing property and entity type names to ValueGenerated messages #29609

Merged
merged 1 commit into from
Nov 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/EFCore/Diagnostics/CoreLoggerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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);
}

/// <summary>
Expand Down Expand Up @@ -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))
Expand All @@ -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);
}

/// <summary>
Expand Down
8 changes: 4 additions & 4 deletions src/EFCore/Properties/CoreStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions src/EFCore/Properties/CoreStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -965,19 +965,19 @@
<comment>Debug CoreEventId.StateChanged string string string EntityState EntityState</comment>
</data>
<data name="LogTempValueGenerated" xml:space="preserve">
<value>'{contextType}' generated a temporary value for the property '{2_entityType}.{1_property}'. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see key values.</value>
<value>'{contextType}' generated a temporary value for the property '{entityType}.{property}'. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see key values.</value>
<comment>Debug CoreEventId.ValueGenerated string string string</comment>
</data>
<data name="LogTempValueGeneratedSensitive" xml:space="preserve">
<value>'{contextType}' generated temporary value '{keyValue}' for the property '{3_entityType}.{2_property}'.</value>
<value>'{contextType}' generated temporary value '{keyValue}' for the property '{entityType}.{property}'.</value>
<comment>Debug CoreEventId.ValueGenerated string object? string string</comment>
</data>
<data name="LogValueGenerated" xml:space="preserve">
<value>'{contextType}' generated a value for the property '{2_entityType}.{1_property}'. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see key values.</value>
<value>'{contextType}' generated a value for the property '{entityType}.{property}'. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see key values.</value>
<comment>Debug CoreEventId.ValueGenerated string string string</comment>
</data>
<data name="LogValueGeneratedSensitive" xml:space="preserve">
<value>'{contextType}' generated value '{keyValue}' for the property '{3_entityType}.{2_property}'.</value>
<value>'{contextType}' generated value '{keyValue}' for the property '{entityType}.{property}'.</value>
<comment>Debug CoreEventId.ValueGenerated string object? string string</comment>
</data>
<data name="ManyToManyOneNav" xml:space="preserve">
Expand Down Expand Up @@ -1496,4 +1496,4 @@
<data name="WrongStateManager" xml:space="preserve">
<value>Cannot start tracking the entry for entity type '{entityType}' because it was created by a different StateManager instance.</value>
</data>
</root>
</root>
8 changes: 4 additions & 4 deletions test/EFCore.Tests/ChangeTracking/ChangeTrackerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -868,19 +868,19 @@ public async Task Value_generation_is_logged(bool sensitive, bool async, bool te
Assert.Equal(
sensitive
? CoreResources.LogTempValueGeneratedSensitive(new TestLogger<TestLoggingDefinitions>()).GenerateMessage(
nameof(LikeAZooContextSensitive), 1, nameof(Hat.Id), nameof(Hat))
nameof(LikeAZooContextSensitive), 1, nameof(Hat), nameof(Hat.Id))
: CoreResources.LogTempValueGenerated(new TestLogger<TestLoggingDefinitions>()).GenerateMessage(
nameof(LikeAZooContext), nameof(Hat.Id), nameof(Hat)),
nameof(LikeAZooContext), nameof(Hat), nameof(Hat.Id)),
message);
}
else
{
Assert.Equal(
sensitive
? CoreResources.LogValueGeneratedSensitive(new TestLogger<TestLoggingDefinitions>()).GenerateMessage(
nameof(LikeAZooContextSensitive), 1, nameof(Hat.Id), nameof(Hat))
nameof(LikeAZooContextSensitive), 1, nameof(Hat), nameof(Hat.Id))
: CoreResources.LogValueGenerated(new TestLogger<TestLoggingDefinitions>()).GenerateMessage(
nameof(LikeAZooContext), nameof(Hat.Id), nameof(Hat)),
nameof(LikeAZooContext), nameof(Hat), nameof(Hat.Id)),
message);
}
}
Expand Down