The namespace of this type doesn't match the project default namespace & directory

23 posts, 0 answers
  1. Rodolfo
    Rodolfo avatar
    5 posts
    Member since:
    Sep 2010

    Posted 22 Jul 2011 Link to this post

    Hi,

    I'm programmign in ASP.Net, what's the correct syntax for this warning?

    The namespace of this type doesn't match the project default namespace & directory

    This appears for the name of Partial Class of my aspx page.

    Thanks
    RS
  2. Ivan
    Admin
    Ivan avatar
    106 posts

    Posted 28 Jul 2011 Link to this post

    Hello Rodolfo,

    Thank you for your feedback. JustCode is warning you that the namespace of a given class does not match the relative path of the file, containing that class. For instance, suppose you have a project called "SampleProject" and a class in a file in the project's folder. Then the correct namespace for that class should be "SampleProject". However, if the class is in a file, which is in a folder "SubFolder" inside that project, then the correct namespace should be "SampleProject.SubFolder". Here is a simple example: http://screencast.com/t/RHyoQwrKV6 .
    You have also the ability to disable that warning from the JustCode menu. Just select: JustCode->Options->Code Analysis->Warnings and the desired language for which to disable the warning.

    Regards,
    Ivan
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. Bill
    Bill avatar
    28 posts
    Member since:
    Apr 2011

    Posted 28 Jul 2011 Link to this post

    I get that same warning in VB.NET WinForms:

    Public Class Test
        Public Property Value As String
    End Class

    shows a green curly line under "Test" with the same warning message.
  4. Christ
    Christ avatar
    7 posts
    Member since:
    Feb 2011

    Posted 02 Aug 2011 Link to this post

    Hi,

    I have the same issue when using delegate definitions in my projects default namespace:

    namespace My.Namespace
    {
      public delegate void MyDelegate (EventArgs e);
    }

    The file that holds this definition is in the root folder of the project. I wonder how to solve the namespace warning here...

    Thanks,
    Christ
  5. Ivan
    Admin
    Ivan avatar
    106 posts

    Posted 02 Aug 2011 Link to this post

    Hello Bill,

    Thank you for your feedback. We show this warning in all C# and VB.NET project types. If the file of the class you have is located directly in the VB project's directory and no namespace is defined explicitly, you should not get this kind of warning. However, if the file is in a subdirectory, a namespace matching the relative path to the project's main directory should be declared. For instance - Namespace SubFolder1.SubFolder2.
    The idea is the same if you have a C# project. The only difference is that you should explicitly type the default namespace of the project. For example : namespace DefaultNamespace.SubFolder1.SubFolder2.
    If you do that and still get this error, could you give us an information how to reproduce it, so we can fix it.
    Your help is highly appreciated!

    Regards,
    Ivan
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  6. Cush
    Cush avatar
    88 posts
    Member since:
    Apr 2010

    Posted 05 Aug 2011 Link to this post

    Hi Ivan

    I am struggling with the same thing here?
    I have just upgraded to the latest version ,ever since the upgrade i have had intellisense giving me this error?

    I have a sub folder called invoices with a form called invoice.aspx contained within it,
    the vb script is

    Partial Class Invoice_invoice

    End Class

    This was fine before the upgrade but now gives a warning?
    However the code runs fine, it just annoying?

    Best Regards

    Cush
  7. Bill
    Bill avatar
    28 posts
    Member since:
    Apr 2011

    Posted 05 Aug 2011 Link to this post

    Under "Code Analysis-Warnings-VisualBasic.Net", I turned off "Show warning for namespaces not matching project default namespace & directory on type identifiers" and that stopped the warning. There is another setting, "Show warning for namespaces not matching project default namespace & directory" that I left turned on. I have no idea what the difference is between the two; the former stopped the warning while the latter did not.
  8. Cush
    Cush avatar
    88 posts
    Member since:
    Apr 2010

    Posted 05 Aug 2011 Link to this post

    Hi Bill

    Thanks very much,
    That got rid of it.

    Best Regards

    Cush
  9. Ivan
    Admin
    Ivan avatar
    106 posts

    Posted 08 Aug 2011 Link to this post

    Hello Bill,

    The warning "Show warning for namespaces not matching project default namespace & directory on type identifiers" appears on type identifiers. For example - if you have a  class is in a namespace that does not match the project default namespace & directory, the warning appears on the class name. Here is a demo : http://screencast.com/t/bkJkxBFfqIU . As for the other warning - it appears on the namespace name - http://screencast.com/t/ucTI9hjKzF9 . If you do not want to get this warning at all, you should disable both of them.
    If you have more questions, please do not hesitate to contact us.


    Your help is highly appreciated!

    Regards,
    Ivan
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  10. Joseph
    Joseph avatar
    1 posts
    Member since:
    Oct 2012

    Posted 30 Oct 2012 Link to this post

    Thanks for this helpful post!
  11. Massimiliano
    Massimiliano avatar
    185 posts
    Member since:
    Oct 2012

    Posted 14 Dec 2012 Link to this post

    It's odd I'm having this error in this circumstances:

    The project name is:
    PRJ.Core

    The folder in wich the class is contained is called "Settings".

    Yet if I use the namespace PRJ.Core.Settings in a class inside that folder I get the warning. Maybe A project name with . cause issues?
  12. Zdravko
    Admin
    Zdravko avatar
    657 posts

    Posted 17 Dec 2012 Link to this post

    Hi Massimiliano,

     Thanks for contacting us.
    I think that you have different warning than the mentioned in this topic. I think that you receive : "Name does not match the naming convention. Suggested name Prj.Core.Setting" which is caused by the acronym that you are using PRJ. By default JustCode supports acronyms which are two letters long. If you want to add some other acronym with different length you should add it manually at JustCode's menu > Options > Code Style > specific language (e.g. C#) > Naming Conventions . There in the right side window you will notice Allowed Acronyms text box. Add there PRJ and the warning will disappear.
    I hope this will help you.
    Thanks.

    Please, do not hesitate to contact us if you have any further questions or need of assistance.

    All the best,
    Zdravko
    the Telerik team
    Share what you think about JustCode with us, so we can help you even better! You can use the built-in feedback tool inside JustCode, our forum, or our JustCode feedback portal.
  13. Chris
    Chris avatar
    4 posts
    Member since:
    May 2013

    Posted 19 Aug 2013 Link to this post

    Hi, 

    Is there a way of flagging a folder to be ignored i.e. the App_Code folder so that the namespaces start from the folders within the App_Code folder. I would like a class called Membership found in the App_Code/Security folder to be in the namespace Security not App_Code.Security 

    Cheers

    Chris
  14. Siyka Marinova
    Admin
    Siyka Marinova avatar
    11 posts

    Posted 20 Aug 2013 Link to this post

    Hi,

     Yes, JustCode provides a "Do Not Contribute to Namespace" property inside Visual Studio's Properties window. All you need to do is select the folder in Solution Explorer and set the property value to "True".
    Here is a short video showing how to do that.

    If you have other questions, please do not hesitate to contact us.

    Regards,

    Siyka Marinova
    Telerik
    Share what you think about JustCode with us, so we can help you even better! You can use the built-in feedback tool inside JustCode, our forum, or our JustCode feedback portal.
  15. Chris
    Chris avatar
    4 posts
    Member since:
    May 2013

    Posted 20 Aug 2013 Link to this post

    Hi Siyka,

    Thank you for your prompt reply this sound perfect but I don't appear to get this option in the properties window when I select the app_code folder.

    I'm running a trial version of JustCode 2013.2 726 at the moment on Visual Studio 2012 vs 11.06315.01 Update 2. Can you see any reason why this option would not appear?

    Cheers

    Chris



     
  16. Siyka Marinova
    Admin
    Siyka Marinova avatar
    11 posts

    Posted 20 Aug 2013 Link to this post

    Hi Chris,

     Unfortunately I cannot reproduce your problem. Could you please open a support ticket and, if possible, attach a sample solution to help us pinpoint the problem?

    Thanks!

    Greetings,
    Siyka Marinova
    Telerik
    Share what you think about JustCode with us, so we can help you even better! You can use the built-in feedback tool inside JustCode, our forum, or our JustCode feedback portal.
  17. Chris
    Chris avatar
    4 posts
    Member since:
    May 2013

    Posted 20 Aug 2013 Link to this post

    Hi Siyka,

    Ok no problem, we will be purchasing a full licence soon so I will see if that resolves the issue first.

    Thanks for your time.

    Cheers

    Chris 
  18. Siyka Marinova
    Admin
    Siyka Marinova avatar
    11 posts

    Posted 21 Aug 2013 Link to this post

    Hi Chris,

     There is one more thing I'd like to know, just to be sure we're on the right track: what type of project do you use?

    Greetings,
    Siyka Marinova
    Telerik
    Share what you think about JustCode with us, so we can help you even better! You can use the built-in feedback tool inside JustCode, our forum, or our JustCode feedback portal.
  19. Chris
    Chris avatar
    4 posts
    Member since:
    May 2013

    Posted 22 Aug 2013 Link to this post

    Hi Siyka,

    I am using a pre-existing project that would have been a C# Web Site, however I have also tried creating a Telerik project and had the same problem. Out of interest can this setting be manually configured in the settings xml file?

    Cheers

    Chris 
  20. Siyka Marinova
    Admin
    Siyka Marinova avatar
    11 posts

    Posted 23 Aug 2013 Link to this post

    Hi Chris,

     Thanks for the additional information, it helped us clarify the problem. The "Do Not Contribute to Namespace" property is not available in WebSites and currently it is not possible to configure this setting manually. I logged an item for that in our backlog, so stay tuned!

    Regards,
    Siyka Marinova
    Telerik
    Share what you think about JustCode with us, so we can help you even better! You can use the built-in feedback tool inside JustCode, our forum, or our JustCode feedback portal.
  21. John Adams
    John Adams avatar
    1 posts
    Member since:
    May 2013

    Posted 11 Sep 2013 Link to this post

    I'm seeing the same error, but I think my directory/namespace is correct (either that, or the rules are not obvious at all).

    Top-level Solution name: TicTacTokeWCFSvc
    Project Name: Library

    The name of my class is 'ITicTacToe.cs', and it's namespace is 'TicTacToeWCFSvc.Library'.

    I see the error on my screen, and the directory/folder names and filenames all appear to be correct.

    Attached is a screenshot of my VisualStudio2010 screen.



    Nate
  22. Haley01
    Haley01 avatar
    1 posts
    Member since:
    Jun 2013

    Posted 13 Sep 2013 Link to this post

    Hello Rodolfo,

    I think you should try following syntax for the problem :
    name = <namespace identifier> separator <local name> and get proper solution.

    Thanks for sharing the post. Great job.....

  23. Zdravko
    Admin
    Zdravko avatar
    657 posts

    Posted 16 Sep 2013 Link to this post

    Hi Nate,

     Thanks for the screenshot.
    The namespace should start with the current project name (e.g. Library) and then continue with the folder name (if there is any).
    I am not sure what the warning says, but if you execute the "Fix Namespace" command from the Visual Aid > Fix menu your namespace should become 'Library', because this is your project name and the interface is not in a folder.
    Thanks.

    Regards,
    Zdravko
    Telerik
    Share what you think about JustCode with us, so we can help you even better! You can use the built-in feedback tool inside JustCode, our forum, or our JustCode feedback portal.
Back to Top