KreativJos / csharpextensions

C# Extensions for Visual Studio Code
MIT License
74 stars 35 forks source link

`useFileScopedNamespace` does not work #103

Closed lonix1 closed 2 years ago

lonix1 commented 2 years ago

I set "csharpextensions.useFileScopedNamespace": true.

But a class is still generated like this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace MyProject                                  // <---
{                                                    // <---
    public class Blorp
    {

    }
}

Instead of this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace MyProject;

public class Blorp
{

}

Context extension 1.7.0 vscode 1.69.2

bard83 commented 2 years ago

Tested locally with the same configuration and works.

Anyway I've experienced once in the past and I've solved unistalling and then reinstalling the extension.

Let us know if it works.

lonix1 commented 2 years ago

Thanks.

Just tried it again

bard83 commented 2 years ago

Can you please provide a more detailed structure example of the projects and the location where you actually are creating the component?

lonix1 commented 2 years ago

My workspace is quite complex, but it's something like this:

workspace root
  src
    Directory.Build.props
    Organisation1
      Foo
        Foo.csproj
      Foo.Tests
        Foo.Tests,csproj
    Organisation2
      Bar
        Bar.csproj
      Bar.Tests
        Bar.Tests.csproj

Right click on project "Foo", New C# Class, ...

It will have the old namespace format namespace Foo { } instead of namespace Foo;

Hope that helps...

bard83 commented 2 years ago

Are your projects using .net 6 or greater?

lonix1 commented 2 years ago

Yes. I also have a Directory.Build.props, I've updated the schema above to show its location.

If you can't replicate this, then it's "just me". So feel free to close. Maybe someone else will also have this problem and we can find a way to repro.

bard83 commented 2 years ago

can you provide the content of you projects file, please?

lonix1 commented 2 years ago

Hey @bard83 I'm gonna close for now, and let's talk about this again if someone else has the same problem?

I feel like I've wasted too much of your time... :smile:

Thanks for your help!