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

Problem with Generic types #3

Closed
bliet opened this issue Jun 1, 2023 · 1 comment
Closed

Problem with Generic types #3

bliet opened this issue Jun 1, 2023 · 1 comment
Assignees
Labels
bug Something isn't working
Milestone

Comments

@bliet
Copy link

bliet commented Jun 1, 2023

I have a problem to check types that have methods with generic types.
The explementation for the failing type is "Has dependency on: T1&"

How I can allow this dep or ignore it?

Test

PolicyResults results = Policy.Define("Deps", "Desc")
            .For(Types.InAssembly(typeof(KeyValuePairExtensions).Assembly))
            .Add(types => types.That()
                .ResideInNamespace("NetArchExample.Utils")
                .ShouldNot()
                .HaveDependencyOtherThan("NetArchExample.Utils", "System"))
            .Evaluate();

        foreach (var result in results.Results)
        {
            Assert.IsTrue(result.IsSuccessful);
        }

Code

namespace NetArchExample.Utils
{
    using System.Collections.Generic;

    /// <summary>
    /// Class KeyValuePairExtensions.
    /// </summary>
    public static class KeyValuePairExtensions
    {
        /// <summary>
        /// Deconstruct a key value pair.
        /// </summary>
        /// <param name="tuple">The tuple.</param>
        /// <param name="key">The deconstructed key.</param>
        /// <param name="value">The deconstructed value.</param>
        /// <typeparam name="T1">The type of the key.</typeparam>
        /// <typeparam name="T2">The type of the value.</typeparam>
        public static void Deconstruct<T1, T2>(this KeyValuePair<T1, T2> tuple, out T1 key, out T2 value)
        {
            key = tuple.Key;
            value = tuple.Value;
        }
    }
}
@NeVeSpl NeVeSpl added the bug Something isn't working label Jun 1, 2023
@NeVeSpl NeVeSpl self-assigned this Jun 1, 2023
@NeVeSpl NeVeSpl added this to the v1.3.6 milestone Jun 1, 2023
NeVeSpl added a commit that referenced this issue Jun 1, 2023
@NeVeSpl
Copy link
Owner

NeVeSpl commented Jun 1, 2023

Type placeholders out T1 and out T2 were incorrectly detected as dependencies, it should work on v1.3.6 without any change.

@NeVeSpl NeVeSpl closed this as completed Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants