Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix namespace for current document #5

Open
giggio opened this issue Nov 7, 2014 · 12 comments
Open

Fix namespace for current document #5

giggio opened this issue Nov 7, 2014 · 12 comments

Comments

@giggio
Copy link
Member

giggio commented Nov 7, 2014

If a file is located at:
$solutionDir\$projectDir\Folder1\Folder2\file.cs
And the root namespace is Project then the namespace for the file should be Project.Folder1.Folder2.

@giggio
Copy link
Member Author

giggio commented Nov 16, 2014

I have been trying to work this issue, but I do not yet know where to start, as I can't seem to find the Default Namespace setting in the Roslyn APIs. I will follow up with the C# team, if I find something about it I will continue. @ElemarJR @viniciushana @carloscds any idea on how to move this forward?

@carloscds
Copy link
Contributor

I think that is not wasy to solve this, because Namespace can be anything, not properly a list of files.

@sharwell
Copy link
Contributor

This should be co-implemented with an alternative code fix to move the file to the correct location reflecting the namespace. This feature is closely related to DotNetAnalyzers/Proposals#13.

@giggio giggio assigned carloscds and unassigned giggio Nov 17, 2014
@giggio
Copy link
Member Author

giggio commented Nov 17, 2014

@carloscds told me he is working on it now. He said he solved the file location problem. I can't wait to see it.

@carloscds
Copy link
Contributor

@giggio Now it´s working, but I need help to write test. Maybe we need to change some tests methods.

@giggio
Copy link
Member Author

giggio commented Nov 18, 2014

I am reopening the issue, as we still need to progress on the issue. Also, see PR #38.

@giggio
Copy link
Member Author

giggio commented Nov 20, 2014

We still have work to do here, one idea may be to watch the csproj/kproj and get the information from there. Not giving up on this one yet.

@carloscds
Copy link
Contributor

@giggio You can't read file from analyzer because it's a PCL.I have write this in issue PR #38, and according to Microsoft is not a good idea change PCL to a normal class library. But if you can try...

@giggio
Copy link
Member Author

giggio commented Nov 21, 2014

We can use System.IO to read the file. I am not sure about FileSystemWatcher, though.

@carloscds
Copy link
Contributor

@giggio System.IO is partially support by PCL. I have a complete code for this, but when I put into analyzer, my code breaks because PCL doesn't implement System.IO.Directory

@giggio
Copy link
Member Author

giggio commented Nov 21, 2014

We would need to read a file, parse it, and find the default namespace. If we can add a FileSystemWatcher to refresh it when the file changes than it is better. We don't need the Directory class.

@carloscds
Copy link
Contributor

You need read file and find RootNameSpace. As I tell, I have create this code that get some source file in project identity your csproj (check if this source is part of this csproj) and after this get RootNamespace. I'm curious about how FileSysteWatcher can identity correct csproj file in a complex solution.
If you solve this (identity csproj anbd read rootnamespace)we have another fix, because it is my orrent problem.

@giggio giggio added the C# label Dec 1, 2014
@giggio giggio added the Blocked label Apr 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants