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

Request Support for InternalsVisibleTo with Exclude Symbol #14

Closed
ristogod opened this issue Jun 14, 2024 · 0 comments
Closed

Request Support for InternalsVisibleTo with Exclude Symbol #14

ristogod opened this issue Jun 14, 2024 · 0 comments

Comments

@ristogod
Copy link

ristogod commented Jun 14, 2024

We have some assemblies that share internals with other assemblies. This is causing some warning and ambiguity issues:

'D:...Services\obj\Release\net8.0-windows\AutoRegisterInject\AutoRegisterInject.Generator\AutoRegisterInject.Attributes.g.cs' conflicts with the imported type 'TryRegisterTransientAttribute' in '....Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. 
Using the type defined in 'D:...Services\obj\Release\net8.0-windows\AutoRegisterInject\AutoRegisterInject.Generator\AutoRegisterInject.Attributes.g.cs'.

Other generator projects I've used will sometimes provide a symbol to control whether internals are generated or not.

<Project Sdk="Microsoft.NET.Sdk">

   <PropertyGroup>
      <DefineConstants>$(DefineConstants);AUTOREGISTERINJECT_EXCLUDE_ATTRIBUTES</DefineConstants>
   </PropertyGroup>

</Project>
// <auto-generated>
//     Automatically generated by AutoRegisterInject.
//     Changes made to this file may be lost and may cause undesirable behaviour.
// </auto-generated>
#if !AUTOREGISTERINJECT_EXCLUDE_ATTRIBUTES
[System.AttributeUsage(System.AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
internal sealed class RegisterScopedAttribute : System.Attribute
{ 
    internal RegisterScopedAttribute(params System.Type[] onlyRegisterAs) { }
}

[System.AttributeUsage(System.AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
internal sealed class RegisterKeyedScopedAttribute : System.Attribute
{ 
    internal RegisterKeyedScopedAttribute(string serviceKey, params System.Type[] onlyRegisterAs) { }
}

[System.AttributeUsage(System.AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
internal sealed class TryRegisterScopedAttribute : System.Attribute
{ 
    internal TryRegisterScopedAttribute(params System.Type[] onlyRegisterAs) { }
}

[System.AttributeUsage(System.AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
internal sealed class TryRegisterKeyedScopedAttribute : System.Attribute
{ 
    internal TryRegisterKeyedScopedAttribute(string serviceKey, params System.Type[] onlyRegisterAs) { }
}

[System.AttributeUsage(System.AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
internal sealed class RegisterSingletonAttribute : System.Attribute
{ 
    internal RegisterSingletonAttribute(params System.Type[] onlyRegisterAs) { }
}

[System.AttributeUsage(System.AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
internal sealed class RegisterKeyedSingletonAttribute : System.Attribute
{ 
    internal RegisterKeyedSingletonAttribute(string serviceKey, params System.Type[] onlyRegisterAs) { }
}

[System.AttributeUsage(System.AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
internal sealed class TryRegisterSingletonAttribute : System.Attribute
{ 
    internal TryRegisterSingletonAttribute(params System.Type[] onlyRegisterAs) { }
}

[System.AttributeUsage(System.AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
internal sealed class TryRegisterKeyedSingletonAttribute : System.Attribute
{ 
    internal TryRegisterKeyedSingletonAttribute(string serviceKey, params System.Type[] onlyRegisterAs) { }
}

[System.AttributeUsage(System.AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
internal sealed class RegisterTransientAttribute : System.Attribute
{ 
    internal RegisterTransientAttribute(params System.Type[] onlyRegisterAs) { }
}

[System.AttributeUsage(System.AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
internal sealed class RegisterKeyedTransientAttribute : System.Attribute
{ 
    internal RegisterKeyedTransientAttribute(string serviceKey, params System.Type[] onlyRegisterAs) { }
}

[System.AttributeUsage(System.AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
internal sealed class TryRegisterTransientAttribute : System.Attribute
{ 
    internal TryRegisterTransientAttribute(params System.Type[] onlyRegisterAs) { }
}

[System.AttributeUsage(System.AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
internal sealed class TryRegisterKeyedTransientAttribute : System.Attribute
{ 
    internal TryRegisterKeyedTransientAttribute(string serviceKey, params System.Type[] onlyRegisterAs) { }
}

[System.AttributeUsage(System.AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
internal sealed class RegisterHostedServiceAttribute : System.Attribute { }
#endif

Here's the PR for my suggested changes

#15

Thanks,

@ristogod ristogod closed this as not planned Won't fix, can't repro, duplicate, stale Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant