简体   繁体   中英

How get default namespace of project with roslyn?

I have an c# project. I have renamed NameSpaceDeclarationSyntax for example namespace1 to namespace2 . When I compiled this project with visual studio and roslyn api I find out that visual studio has embedded the all resources of project with namespace2 just the resources file in properties folder has embedded with default namespace of project.

I have embedded all resources with namespace2 with roslyn and because of this it doesn't run .

the following exception had thrown :

Couldn't find any resources appropriate for specified culture or the neutral culture. Make sure namespace1.properties.Resources.resources was correctly embedded or linked into assembly "assemblyname" ...

I must change the default namespace of project or get the default namespace and embed with that but I don't know how find or change default namespace of project ?

The default namespace is a property of MSBuild and Visual Studio, not the compilers themselves. Therefore, you won't find it in the Roslyn API.

Instead, you can change the <RootNamespace> element directly in the project file.

You can see how Roslyn's Visual Studio layers get the default namespace here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM