Copying a class that has a missing dependency in a fresh document does not indicate that the dependency is missng

Hey,

Was playing with the Use Configuration help patch from latest previews, awesome feature!

I tried copying the MyStartup class definition in my project. I knew the dependency to Microsoft.Extensions.Configuration.Json would be missing in my app, so I would have expected the Document menu to turn red and propose me to install the dependency.

But the editor does not give me a hint, I have to manually type the nuget install command.

Repro, in 6.0-11 :

  • Make sure you remove Microsoft.Extensions.Configuration.Json from your installed nugets
  • Open the HowTo Use Configuration help patch
  • Copy the MyStartup class definition
  • Paste it in your own project : the editor won’t tell you the dependency is missing

Cheers!

Not sure how to address this one. As long as the package is not installed the system will not know where the node AddJsonFile stems from. For the system it’s simply a pointer to something it can’t find. Now if you copy it to another patch it can’t really add a dependency to something it doesn’t know about.

I thought the origin of the node was now carried with it when pasting in a different document, with this new feature that automagically adds a dependency to a package when you copy from a help patch for instance!

Yes, and when you install the package while being in the help patch it will also carry that dependency over. But that only works once it knows about the package.

Thinking about it - we could use the information stored on the node itself. But I think it currently doesn’t say whether it’s a package or a file… and changing something in the xml file is always quite tricky, so reason for it should be a really strong one ;)