Skip to content

Commit

Permalink
Fixed Globalization tests not including IFormatProvider in parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
ronnygunawan committed Oct 9, 2019
1 parent 4f4ccc5 commit 35824a6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions CsvSerializer/CsvSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
using System.Security;
using System.Text;

#if DEBUG
//#if DEBUG
[assembly: InternalsVisibleTo("Tests")]
#endif
//#endif
[assembly: InternalsVisibleTo("CsvSerializer.Dynamic")]
[assembly: AllowPartiallyTrustedCallers]
[assembly: SecurityTransparent]
Expand Down
2 changes: 1 addition & 1 deletion CsvSerializer/CsvSerializer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<RepositoryUrl>https://github.com/ronnygunawan/csv-serializer</RepositoryUrl>
<PackageTags>csv serializer deserializer parser core</PackageTags>
<Description>Fast CSV to object serializer and deserializer.</Description>
<Version>1.0.5</Version>
<Version>1.0.7</Version>
<PackageReleaseNotes></PackageReleaseNotes>
</PropertyGroup>

Expand Down
14 changes: 7 additions & 7 deletions CsvSerializer/Internal/NativeImpl/SerializerFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ internal static class SerializerFactory {

public static ISerializer GetOrCreate<T>() where T : notnull {
if (_cache.TryGetValue(typeof(T), out ISerializer? serializer)) return serializer;
if (TypeHelper.IsInternalOrAnonymous<T>()) {
//if (TypeHelper.IsInternalOrAnonymous<T>()) {
serializer = new NaiveSerializer<T>();
} else {
ImplEmitter<ISerializer> implEmitter = new ImplEmitter<ISerializer>($"S{typeof(T).GUID.ToString("N")}");
implEmitter.ImplementAction<char, StringBuilder>("SerializeHeader", gen => DefineSerializeHeader<T>(gen));
implEmitter.ImplementAction<IFormatProvider, char, StringBuilder, object>("SerializeItem", gen => DefineSerializeItem<T>(gen));
serializer = implEmitter.CreateInstance();
}
//} else {
// ImplEmitter<ISerializer> implEmitter = new ImplEmitter<ISerializer>($"S{typeof(T).GUID.ToString("N")}");
// implEmitter.ImplementAction<char, StringBuilder>("SerializeHeader", gen => DefineSerializeHeader<T>(gen));
// implEmitter.ImplementAction<IFormatProvider, char, StringBuilder, object>("SerializeItem", gen => DefineSerializeItem<T>(gen));
// serializer = implEmitter.CreateInstance();
//}
_cache.TryAdd(typeof(T), serializer);
return serializer;
}
Expand Down
16 changes: 8 additions & 8 deletions Tests/InternationalizationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public void CanSerializeAndDeserializeInEN_USLocale() {
Decimal = 123_456.789m,
Double = 123_456.789
};
string csv = CsvSerializer.Serialize(new[] { model });
string csv = CsvSerializer.Serialize(new[] { model }, provider: provider);
DecimalAndDouble[] deserialized = CsvSerializer.Deserialize<DecimalAndDouble>(csv, provider: provider);
deserialized.Length.Should().Be(1);
model = deserialized[0];
Expand All @@ -28,7 +28,7 @@ public void CanSerializeAndDeserializeInEN_GBLocale() {
Decimal = 123_456.789m,
Double = 123_456.789
};
string csv = CsvSerializer.Serialize(new[] { model });
string csv = CsvSerializer.Serialize(new[] { model }, provider: provider);
DecimalAndDouble[] deserialized = CsvSerializer.Deserialize<DecimalAndDouble>(csv, provider: provider);
deserialized.Length.Should().Be(1);
model = deserialized[0];
Expand All @@ -43,7 +43,7 @@ public void CanSerializeAndDeserializeInID_IDLocale() {
Decimal = 123_456.789m,
Double = 123_456.789
};
string csv = CsvSerializer.Serialize(new[] { model });
string csv = CsvSerializer.Serialize(new[] { model }, provider: provider);
DecimalAndDouble[] deserialized = CsvSerializer.Deserialize<DecimalAndDouble>(csv, provider: provider);
deserialized.Length.Should().Be(1);
model = deserialized[0];
Expand All @@ -58,7 +58,7 @@ public void CanSerializeAndDeserializeInEN_INLocale() {
Decimal = 123_456.789m,
Double = 123_456.789
};
string csv = CsvSerializer.Serialize(new[] { model });
string csv = CsvSerializer.Serialize(new[] { model }, provider: provider);
DecimalAndDouble[] deserialized = CsvSerializer.Deserialize<DecimalAndDouble>(csv, provider: provider);
deserialized.Length.Should().Be(1);
model = deserialized[0];
Expand All @@ -73,7 +73,7 @@ public void CanSerializeAndDeserializeInFR_FRLocale() {
Decimal = 123_456.789m,
Double = 123_456.789
};
string csv = CsvSerializer.Serialize(new[] { model });
string csv = CsvSerializer.Serialize(new[] { model }, provider: provider);
DecimalAndDouble[] deserialized = CsvSerializer.Deserialize<DecimalAndDouble>(csv, provider: provider);
deserialized.Length.Should().Be(1);
model = deserialized[0];
Expand All @@ -88,7 +88,7 @@ public void CanSerializeAndDeserializeInDE_DELocale() {
Decimal = 123_456.789m,
Double = 123_456.789
};
string csv = CsvSerializer.Serialize(new[] { model });
string csv = CsvSerializer.Serialize(new[] { model }, provider: provider);
DecimalAndDouble[] deserialized = CsvSerializer.Deserialize<DecimalAndDouble>(csv, provider: provider);
deserialized.Length.Should().Be(1);
model = deserialized[0];
Expand All @@ -103,7 +103,7 @@ public void CanSerializeAndDeserializeInZH_CNLocale() {
Decimal = 123_456.789m,
Double = 123_456.789
};
string csv = CsvSerializer.Serialize(new[] { model });
string csv = CsvSerializer.Serialize(new[] { model }, provider: provider);
DecimalAndDouble[] deserialized = CsvSerializer.Deserialize<DecimalAndDouble>(csv, provider: provider);
deserialized.Length.Should().Be(1);
model = deserialized[0];
Expand All @@ -118,7 +118,7 @@ public void CanSerializeAndDeserializeInAR_SALocale() {
Decimal = 123_456.789m,
Double = 123_456.789
};
string csv = CsvSerializer.Serialize(new[] { model });
string csv = CsvSerializer.Serialize(new[] { model }, provider: provider);
DecimalAndDouble[] deserialized = CsvSerializer.Deserialize<DecimalAndDouble>(csv, provider: provider);
deserialized.Length.Should().Be(1);
model = deserialized[0];
Expand Down

0 comments on commit 35824a6

Please sign in to comment.