Skip to content

Commit

Permalink
Allowed null Namespace for Framework Types
Browse files Browse the repository at this point in the history
Co-authored-by: Mike-E <michael@dragonspark.network>
  • Loading branch information
oliver-chime and Mike-E-angelo authored Sep 1, 2020
1 parent 6d6b363 commit ffd3a89
Showing 1 changed file with 6 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,30 +1,20 @@
using ExtendedXmlSerializer.Core.Specifications;
using System.Reflection;

namespace ExtendedXmlSerializer.ContentModel.Reflection
{
sealed class PartitionedTypeSpecification
: DecoratedSpecification<TypeInfo>,
IPartitionedTypeSpecification
sealed class PartitionedTypeSpecification : IPartitionedTypeSpecification
{
public static PartitionedTypeSpecification Default { get; } = new PartitionedTypeSpecification();

PartitionedTypeSpecification() : base(NotHappy.Default) {}
}

sealed class NotHappy : ISpecification<TypeInfo>
// HACK: This is a bit of a hack -- ok a total hack, to pass a test for .NET Framework under special conditions: https://github.com/ExtendedXmlSerializer/home/issues/248
// This doesn't occur for .NET Core, but we will have to do better for v3 in any case.
{
public static NotHappy Default { get; } = new NotHappy();

NotHappy() : this(typeof(object).Assembly) {}
PartitionedTypeSpecification() : this(typeof(object).Assembly) {}

readonly Assembly _assembly;

public NotHappy(Assembly assembly) => _assembly = assembly;
public PartitionedTypeSpecification(Assembly assembly) => _assembly = assembly;

// HACK: This is a bit of a hack -- ok a total hack, to pass a test for .NET Framework under special conditions:
// https://github.com/ExtendedXmlSerializer/home/issues/248
public bool IsSatisfiedBy(TypeInfo parameter)
=> parameter.Assembly != _assembly || !parameter.Namespace.Contains("System.Runtime.Remoting");
=> parameter.Assembly != _assembly || (!parameter.Namespace?.Contains("System.Runtime.Remoting") ?? true);
}
}

0 comments on commit ffd3a89

Please sign in to comment.