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

Solution.AddAdditionalDocument does not add a new file with AdditionalFiles item type #4655

Open
vweijsters opened this issue Aug 19, 2015 · 31 comments
Assignees
Labels
Area-IDE Bug Concept-API This issue involves adding, removing, clarification, or modification of an API. help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Milestone

Comments

@vweijsters
Copy link
Contributor

When adding a new file to a solution from within a codefix provider using the Solution.AddAdditionalDocument method, the file gets added with an item type of None where an item type of AdditionalFiles is expected.

This issue was observed using VS2015 RTM with roslyn 1.0.0

@jasonmalinowski
Copy link
Member

@vweijsters, can you clarify what your scenario is? What type of file is the file you're trying to add? I ask only because there's a few other bugs floating around in this area that might fix your underlying need and I'd like to confirm.

@vweijsters
Copy link
Contributor Author

I'm adding a default JSON settings file that will (in the future) be parsed by analyzers as means of configuration. The important part for me is that the added file will show up in the AnalyzerOptions.AdditionalFiles collection.

A first version of the code is available DotNetAnalyzers/StyleCopAnalyzers#1250
The codefix provider can be found here

@sharwell
Copy link
Member

👍

@Pilchie Pilchie added the Concept-API This issue involves adding, removing, clarification, or modification of an API. label Aug 20, 2015
@Pilchie Pilchie added this to the 1.1 milestone Aug 20, 2015
@jasonmalinowski
Copy link
Member

@vweijsters: thanks. In your case, the settings file name is always known, right? It's always stylecop.json?

@sharwell
Copy link
Member

@jasonmalinowski That's correct. It opens some possibilities regarding the inclusion of a .targets file in our NuGet package, but I was trying to avoid that.

@paul1956
Copy link
Contributor

@jasonmalinowski in my case I am adding a JSON file with a different name and still expect it to be an "AdditionalFile". I am adding it in a non-PCL project but want to read it in an Analyzer/Diagnostic using the Projects AdditionalFiles method which right now returns Nothing unless I hand edit the project file.

@paul1956
Copy link
Contributor

"Projects AdditionFiles method" above should read "AnalyzerOptions.AdditionalFiles collection". Can't correct on phone.

@twsouthwick
Copy link
Member

I'm encountering this as well (same scenario as @vweijsters). Any updates?

@jasonmalinowski
Copy link
Member

No updates, sorry.

@sharwell
Copy link
Member

@twsouthwick Take a look at how we are now handling this in DotNetAnalyzers/StyleCopAnalyzers#1790. Obviously it's not ideal, but it's enough to make sure that users aren't left with completely broken functionality 😄

@twsouthwick
Copy link
Member

Thanks @sharwell . We're already doing something similar to that. I was trying to add a codefix that would add a default config file so the VSIX version could be useful without requiring the user to open up the proj file.

@heaths
Copy link

heaths commented Apr 23, 2016

Rather than try to change the nupkg so that AdditionalItems is used instead of None, why not just change how stylecop.json is found like some other tools (including NuGet) that search up from the project directory looking for it? That way, we can put a single stylecop.json in the solution root and all projects will use it automatically. If a project wants to override, have a project-local copy with changes. Lots of tools work this way, like git with .gitignore.

@Pilchie Pilchie modified the milestones: 2.0 (RC), 1.3 May 27, 2016
@Pilchie Pilchie modified the milestones: 2.0 (Preview 5), 2.0 (RC) Sep 26, 2016
@danmendonca
Copy link

The workaround of this issue for what I am understanding (the above mentioned), depends on knowing the file name from the beginning. Has someone found another way? I guess this is low in the priority list.

@jnm2
Copy link
Contributor

jnm2 commented Oct 15, 2017

I'm blocked on this too. I can't just update via NuGet tools because the path needs to be customized to the individual repository.

@RubenMateus
Copy link

Any news from this? Really would like to add style cop to project

@tpodolak
Copy link

Any updates on this one?

@gruckion
Copy link

This was started back in 2015 and it's still not closed? What is the progress of this item?

@jasonmalinowski jasonmalinowski modified the milestones: 16.0, Backlog Jan 17, 2019
@TannerBragg
Copy link

Any progress or update?

@dropsonic
Copy link

Bumped into the same issue. Any news on that?

@calebccff
Copy link

Just to add a note, I thought I was running into this issue too but it turns out stylecop.json was in my .gitignore so it didn't get read by visual studio.

@dropsonic
Copy link

5 years passed, any updates? This issue is critical if you want to add your own configuration files from the Roslyn-based extension.

@hypercodeplace
Copy link

The same issue. Do you have any updates on this?

@GarretWayne
Copy link

Just a friendly reminder that this is still an issue, unfixed. Could you please fix it?

@CyrusNajmabadi
Copy link
Member

@GarretWayne this is in the backlog currently. If you are interested in fixing it though we would certainly take a community contribution. Thanks!

@mikeblas
Copy link

mikeblas commented Sep 6, 2022

The published workaround doesn't mention Visual Studio 2022. I think the name of the choice has changed to "C# Analyzer Additional File" in that release.

@taori
Copy link

taori commented Dec 17, 2023

@GarretWayne this is in the backlog currently. If you are interested in fixing it though we would certainly take a community contribution. Thanks!

Can you add the "up for grabs" tag, please?

@GarretWayne
Copy link

@GarretWayne this is in the backlog currently. If you are interested in fixing it though we would certainly take a community contribution. Thanks!

Can you add the "up for grabs" tag, please?

Unfortunately, I'm unable to apply labels to this conversation. :(

@CyrusNajmabadi
Copy link
Member

@GarretWayne You're always welcome to contribute. I'll add the tag as well, but it's not a requirement for that.

@CyrusNajmabadi CyrusNajmabadi added the help wanted The issue is "up for grabs" - add a comment if you are interested in working on it label Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Bug Concept-API This issue involves adding, removing, clarification, or modification of an API. help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Projects
None yet
Development

No branches or pull requests