-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added check for "unspeakable" types.
- Loading branch information
1 parent
d9c07ef
commit afd61d4
Showing
5 changed files
with
57 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/ExtendedXmlSerializer/ContentModel/Reflection/GenericTypes.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
src/ExtendedXmlSerializer/ReflectionModel/ApplicationTypeSpecification.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
using ExtendedXmlSerializer.Core.Specifications; | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using ExtendedXmlSerializer.Core.Specifications; | ||
|
||
namespace ExtendedXmlSerializer.ReflectionModel | ||
{ | ||
class ApplicationTypeSpecification : InverseSpecification<TypeInfo> | ||
sealed class ApplicationTypeSpecification : InverseSpecification<TypeInfo> | ||
{ | ||
public static ApplicationTypeSpecification Default { get; } = new ApplicationTypeSpecification(); | ||
|
||
ApplicationTypeSpecification() : base(IsDefinedSpecification<CompilerGeneratedAttribute>.Default) {} | ||
ApplicationTypeSpecification() | ||
: base(IsDefinedSpecification<CompilerGeneratedAttribute>.Default.Or(IsUnspeakable.Default)) {} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/ExtendedXmlSerializer/ReflectionModel/IsUnspeakable.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using ExtendedXmlSerializer.Core.Specifications; | ||
using System.Reflection; | ||
|
||
namespace ExtendedXmlSerializer.ReflectionModel | ||
{ | ||
/// <summary> | ||
/// Reference: https://stackoverflow.com/a/9256695/10340424 | ||
/// </summary> | ||
sealed class IsUnspeakable : DelegatedSpecification<TypeInfo> | ||
{ | ||
public static IsUnspeakable Default { get; } = new IsUnspeakable(); | ||
|
||
IsUnspeakable() : base(x => x.Name.StartsWith("<")) {} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
test/ExtendedXmlSerializer.Tests.ReportedIssues/Issue470Tests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using ExtendedXmlSerializer.Configuration; | ||
using ExtendedXmlSerializer.Tests.ReportedIssues.Support; | ||
using FluentAssertions; | ||
using JetBrains.Annotations; | ||
using System; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace ExtendedXmlSerializer.Tests.ReportedIssues | ||
{ | ||
public sealed class Issue470Tests | ||
{ | ||
[Fact] | ||
public void Verify() | ||
{ | ||
var instance = new Foo(); | ||
new ConfigurationContainer().Create().ForTesting().Cycle(instance).Should().BeEquivalentTo(instance); | ||
} | ||
|
||
public class Foo | ||
{ | ||
public string Bar { get; set; } | ||
} | ||
|
||
public class Something | ||
{ | ||
[UsedImplicitly] | ||
Func<object, Task> Check<T>(Func<T, Task> data) | ||
{ | ||
return async o => await data((T)o); // this causes it to bomb out | ||
} | ||
} | ||
} | ||
} |