Skip to content
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
6 changes: 6 additions & 0 deletions src/EFCore/Properties/CoreStrings.Designer.cs

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

57 changes: 30 additions & 27 deletions src/EFCore/Properties/CoreStrings.resx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
<!--
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: unrelated whitespace changes (I get this too all of the time)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's because the T4 that we generate from does not create code that conforms to our formatting, so whenever the file is opened in an editor, it changes from what was generated by T4.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I remove the changes (git checkout -p) every time as well. It sucks.

Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
Expand All @@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
Expand Down Expand Up @@ -489,6 +489,9 @@
<data name="EmptyComplexType" xml:space="preserve">
<value>Complex type '{complexType}' has no properties defines. Configure at least one property or don't include this type in the model.</value>
</data>
<data name="EmptyJsonString" xml:space="preserve">
<value>The empty string is not valid JSON.</value>
</data>
<data name="EntityEqualityOnCompositeKeyEntitySubqueryNotSupported" xml:space="preserve">
<value>Cannot translate '{comparisonOperator}' on a subquery expression of entity type '{entityType}' because it has a composite primary key. See https://go.microsoft.com/fwlink/?linkid=2141942 for information on how to rewrite your query.</value>
</data>
Expand Down
5 changes: 5 additions & 0 deletions src/EFCore/Storage/Json/JsonValueReaderWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ internal JsonValueReaderWriter()
/// <returns>The read value.</returns>
public object FromJsonString(string json, object? existingObject = null)
{
if (string.IsNullOrWhiteSpace(json))
{
throw new InvalidOperationException(CoreStrings.EmptyJsonString);
}

var readerManager = new Utf8JsonReaderManager(new JsonReaderData(Encoding.UTF8.GetBytes(json)), null);
readerManager.MoveNext();
return FromJson(ref readerManager, existingObject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1385,6 +1385,48 @@ FROM json_each(@__strings_0) AS "s"
""");
}

[ConditionalTheory]
[InlineData(false)]
[InlineData(true)] // Issue #32896
public async Task Empty_string_used_for_primitive_collection_throws(bool async)
{
await using var connection = new SqliteConnection("DataSource=:memory:");
await connection.OpenAsync();

await using var context = new SimpleContext(connection);
await context.Database.EnsureDeletedAsync();
await context.Database.EnsureCreatedAsync();

await context.Database.ExecuteSqlRawAsync("INSERT INTO SimpleEntities (List) VALUES ('');");

var set = context.SimpleEntities;

var message = await Assert.ThrowsAsync<InvalidOperationException>(
async () =>
{
if (async)
{
await set.FirstAsync();
}
else
{
set.First();
}
});

Assert.Equal(CoreStrings.EmptyJsonString, message.Message);
}

public class SimpleContext(SqliteConnection connection) : DbContext
{
public DbSet<SimpleEntity> SimpleEntities => Set<SimpleEntity>();

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder.UseSqlite(connection);
}

public record SimpleEntity(int Id, IEnumerable<string> List);

[ConditionalFact]
public virtual void Check_all_tests_overridden()
=> TestHelpers.AssertAllMethodsOverridden(GetType());
Expand Down