Skip to content

Commit 03e375a

Browse files
Copilotrenemadsen
andcommitted
Fix code review issue: Use PropertyInfo correctly
Fixed incorrect usage of .GetMethod! on PropertyInfo. Now correctly using the utf8Property in Expression.Property. Co-authored-by: renemadsen <76994+renemadsen@users.noreply.github.com>
1 parent 948f768 commit 03e375a

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

src/EFCore.MySql/Storage/Internal/MySqlJsonTypeMapping.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,7 @@ public override Expression CustomizeDataReaderExpression(Expression expression)
146146
if (expression.Type == typeof(string))
147147
{
148148
// Convert string to MemoryStream: new MemoryStream(Encoding.UTF8.GetBytes(stringValue))
149-
var getBytes = typeof(System.Text.Encoding).GetProperty(nameof(System.Text.Encoding.UTF8))!
150-
.GetMethod!;
149+
var utf8Property = typeof(System.Text.Encoding).GetProperty(nameof(System.Text.Encoding.UTF8))!;
151150
var getBytesMethod = typeof(System.Text.Encoding).GetMethod(
152151
nameof(System.Text.Encoding.GetBytes),
153152
new[] { typeof(string) })!;
@@ -156,7 +155,7 @@ public override Expression CustomizeDataReaderExpression(Expression expression)
156155
return Expression.New(
157156
memoryStreamCtor,
158157
Expression.Call(
159-
Expression.Property(null, getBytes),
158+
Expression.Property(null, utf8Property),
160159
getBytesMethod,
161160
expression));
162161
}

0 commit comments

Comments
 (0)