Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ThatAre[Not]UnderNamespace matches partial namespaces #1196

Closed
jnyrup opened this issue Nov 30, 2019 · 1 comment
Closed

ThatAre[Not]UnderNamespace matches partial namespaces #1196

jnyrup opened this issue Nov 30, 2019 · 1 comment

Comments

@jnyrup
Copy link
Member

jnyrup commented Nov 30, 2019

Description

ThatAreUnderNamespace considers a type to be under a namespace @namespace, if @namespace is a string prefix of its namespace.
That unintendedly allows a type in SystemSomething to be under the namespace System.

Complete minimal example reproducing the issue

namespace SystemPrefixed
{
    class Foo
    {
    }
}
TypeSelector types = new[] { typeof(SystemPrefixed.Foo) }.Types();

types.ThatAreUnderNamespace("System")
    .As<IEnumerable<Type>>()
    .Should()
    .BeEmpty();

Expected behavior:

Foo should not be considered to be under the namespace System.

[What actually happens]

Foo is considered to be under the namespace System.

Additional Information

First reported in #1175
Related to #1193

jnyrup added a commit to jnyrup/fluentassertions that referenced this issue Nov 30, 2019
The namespace of a type not inside any namespace is `null`.
As all types are *under* the global namespace, `ThatAreUnderNamespace` should be able to gracefully handle `null` namespaces.

This also fixes that `ThatAreUnderNamespace` would incorrectly match the
namespace of a type against a partial prefix.

This fixes fluentassertions#1185 and fluentassertions#1196
jnyrup added a commit to jnyrup/fluentassertions that referenced this issue Dec 5, 2019
The namespace of a type not inside any namespace is `null`.
As all types are *under* the global namespace, `ThatAreUnderNamespace` should be able to gracefully handle `null` namespaces.

This also fixes that `ThatAreUnderNamespace` would incorrectly match the
namespace of a type against a partial prefix.

This fixes fluentassertions#1185 and fluentassertions#1196
@jnyrup
Copy link
Member Author

jnyrup commented Dec 5, 2019

Fixed in #1197

@jnyrup jnyrup closed this as completed Dec 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant