Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Feedback Intended behaviour or bug with asmdef / internal / namespace.

Discussion in 'Editor & General Support' started by aurelien-morel-ubiant, Feb 5, 2020.

  1. aurelien-morel-ubiant

    aurelien-morel-ubiant

    Joined:
    Sep 27, 2017
    Posts:
    275
    Hello unity devs !
    we have a special case in our project for us it sounds like a bug due to the error message we get on this.

    We made a sample project to reproduce it easily.
    We have 2 asmdef : asmDefA & asmDefB

    asmDefA contains a script testA
    asmDefB contains a scripts testB

    testA references testB and both are in namespace named asmdefIssue

    TestA.cs
    Code (CSharp):
    1. namespace asmdefIssue
    2. {
    3.     using UnityEngine;
    4.  
    5.     public class testA : MonoBehaviour
    6.     {
    7.         testB damn;
    8.     }
    9. }
    TestB.cs

    Code (CSharp):
    1. namespace asmdefIssue
    2. {
    3.     using UnityEngine;
    4.  
    5.     internal class testB : MonoBehaviour
    6.     {
    7.         public int a;
    8.     }
    9. }
    we made the class testB internal to be sure it will be available only in this particular namespace and this is why the message is triggered.
    If we put it public it works.
    If we put it private it send the same message.
    If we put it protected it send the same message.

    For us internal has a namespace's scope, that's why it sounds odd to us.

    our issue is this :
    Code (CSharp):
    1. Assets\Scripts\asmdef1\testA.cs(7,3): error CS0122: 'testB' is inaccessible due to its protection level
    Is it normal to get this issue because asmDefA contains asmDefB in its references.
    So for us both namespace must be able to communicate between them. This inaccessible message is weird cause for us it must works by linking them correctly or throw an unknown class but not this protection level issue.

    any idea ?
     
  2. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    2,490
    If you're putting scripts in two separate assemblies (that's what asmdef's are for) - it doesn't matter if they're in the same namespace.

    Since they'll end up compiled into separate .dll's - two separate libraries. Dependencies doesn't matter here either.

    And internal means its visible to the same assembly, not namespace.
     
    Last edited: Feb 5, 2020
  3. aurelien-morel-ubiant

    aurelien-morel-ubiant

    Joined:
    Sep 27, 2017
    Posts:
    275
    Ok seems legit. I mixed up both logic my bad !
    Thanks !
     
    xVergilx likes this.
unityunity