Skip to content
This repository was archived by the owner on Nov 28, 2023. It is now read-only.

Commit 8efe42a

Browse files
committed
Add newspec. Avoid Aggregate Exception entirely
1 parent 6cec591 commit 8efe42a

File tree

3 files changed

+27
-28
lines changed

3 files changed

+27
-28
lines changed

src/ServiceStack.Text.EnumMemberSerializer.UnitTests/AssemblyExtenstionsTests.cs

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Collections.ObjectModel;
43
using System.Linq;
54
using System.Reflection;
6-
using System.Reflection.Emit;
75
using SomeOtherNamespace;
86
using Xunit;
97

@@ -92,27 +90,10 @@ public void GetPublicEnums_ListOfNullAssemblies_ReturnsEmtpyTypeList()
9290
public void GetPublicEnums_FilterThrowsException_ExceptionPassedUpInAggregate()
9391
{
9492
var assemblies = new List<Assembly> {Assembly.GetExecutingAssembly()};
95-
Assert.Throws<AggregateException>(
93+
Assert.Throws<NotImplementedException>(
9694
() =>
9795
{
98-
try
99-
{
100-
assemblies.GetPublicEnums(s => { throw new NotImplementedException(); });
101-
}
102-
catch (AggregateException ex)
103-
{
104-
Assert.Equal(
105-
2,
106-
ex.InnerExceptions
107-
.ToList()
108-
.FindAll(x => x.GetType() == typeof (NotImplementedException))
109-
.Count);
110-
throw;
111-
}
112-
catch (Exception)
113-
{
114-
Assert.True(false, "Expected AggregateException");
115-
}
96+
assemblies.GetPublicEnums(s => { throw new NotImplementedException(); });
11697
});
11798
}
11899
}

src/ServiceStack.Text.EnumMemberSerializer/AssemblyExtenstions.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,16 @@ public static HashSet<Type> GetPublicEnums(this ICollection<Assembly> assemblies
2323

2424
foreach (var assembly in assemblies)
2525
{
26-
if (assembly != null)
26+
if (assembly == null)
2727
{
28-
var assemblyPublicEnums =
29-
(from publicEnumType in assembly.GetTypes().GetPublicEnums().AsParallel()
30-
where enumNamespaceFilter(publicEnumType.Namespace)
31-
select publicEnumType
32-
).ToList();
33-
enumTypes.AddRange(assemblyPublicEnums);
28+
continue;
3429
}
30+
var assemblyPublicEnums =
31+
(from publicEnumType in assembly.GetTypes().GetPublicEnums()
32+
where enumNamespaceFilter(publicEnumType.Namespace)
33+
select publicEnumType
34+
).ToList();
35+
enumTypes.AddRange(assemblyPublicEnums);
3536
}
3637
return new HashSet<Type>(enumTypes);
3738
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0"?>
2+
<package >
3+
<metadata>
4+
<id>$id$</id>
5+
<version>$version$</version>
6+
<title>$title$</title>
7+
<authors>$author$</authors>
8+
<owners>$author$</owners>
9+
<licenseUrl>https://github.com/Chatham/ServiceStack.Text.EnumMemberSerializer/blob/master/LICENSE</licenseUrl>
10+
<projectUrl>https://github.com/Chatham/ServiceStack.Text.EnumMemberSerializer</projectUrl>
11+
<iconUrl>http://www.servicestack.net/logo-100x100.png</iconUrl>
12+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
13+
<description>$description$</description>
14+
<copyright>Copyright © Anthony Carl, Chatham Financial Corp. 2013</copyright>
15+
<tags>Serializer TEXT PrettyPrint ServiceStack JSON Service</tags>
16+
</metadata>
17+
</package>

0 commit comments

Comments
 (0)