Solves issue #5 by looking at parent ProjectItem insteed of proj root #6
Conversation
No comments of feedback on this one? I've used it in my VS install for over 3 months without any problems |
Thanks for contributing
|
var containingProject = source.ContainingProject; | ||
if (containingProject == null) return null; | ||
// getting the parent of the clicked project item | ||
var parent = (ProjectItem) source.Collection.Parent; |
golavr
Dec 10, 2018
Owner
What if the source.Collection.Parent
is Project
and not ProjectItem
?
You are going to get cast exception.
What if the source.Collection.Parent
is Project
and not ProjectItem
?
You are going to get cast exception.
Hi! No worries :) I use this extension all the time :) Hmm, why would you look at a transform for a config-file without a parent? Like in your example? Maybe we should just catch an exception like that and show some massage box? Or what are you thinking? Edit: What I mean is that if the -config-files are correctly nested the parent will always be the ”root” config file? Just running a preview on app.config does not really make sense? |
i didn't say w/o parent :) |
@golavr I understand, thats wrong. But why would someone want to run the preview on the "raw" app.config? How would you think that it should be handled? Edit: Should I show an Msgbox with an error in that case? Or what would you say? |
src/ConfigurationTransform/Services/Extensions/ProjectItemExtensions.cs
Outdated
Show resolved
Hide resolved
src/ConfigurationTransform/Services/Extensions/ProjectItemExtensions.cs
Outdated
Show resolved
Hide resolved
I've updated the code to you example and it seems to work fine now. |
@enkelmedia thanks for the fix |
I've updated the PR, since the test was written with only the "Project" as parent in mind I had to rewrite them a little. Now they are checking that a parent Project returns null and a parent ProjectItem actually comes back correct. |
thank you @enkelmedia |
I this that this might be a solution to the issue that the preview does not work for files thats not in the root of the project