0

I Have 3 projects in same solution, each dependent from the one before (DB <- Provider <- WinUI). In DB I defined a Behaviour class that will be used in Providers with a mapper Behavioud class, this last used by WinUI project. (WinUI doesn't depend directly from DB).

Is there a way to hide the clases from DB inside WinUI? this project only should use the provider clases.

enter image description here

enter image description here

cflorenciav
  • 419
  • 1
  • 6
  • 16
  • Just a small point, you can't really prevent _namespaces_ from being shared, and it shouldn't really matter anyways. The only thing you can restrict is if _types_ are accessible. – gunr2171 Apr 30 '22 at 01:32

1 Answers1

2

First, mark the Behaviour class in the DB project as internal.

Second, add

  • for a project that contains an AssemblyInfo.cs file
    [assembly: InternalsVisibleTo("Providers")]
    
  • for .Net 5+, in the csproj file (more info)
    <ItemGroup>
      <InternalsVisibleTo Include="Providers" />
    </ItemGroup>
    

internal prevents the class from being visible in other assemblies. The assembly attribute allows sharing internal classes with the assemblies you name.

gunr2171
  • 16,104
  • 25
  • 61
  • 88