dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
18.71k stars 3.98k forks source link

Metadata As Source doesn't refresh when "framework types" option changes to "predefined types" #13748

Open davkean opened 7 years ago

davkean commented 7 years ago

Metadata as source has started using "framework types" instead of "predefined types":

image

The former is current preview builds, the later is VS 2015.

I cannot figure out how to flip this setting back to what it was (predefined type preferences, which I thought would control this, does not).

yume-chan commented 7 years ago

Metadata As Source now follows the Code Style settings for using framework types or predefined types, this is actually an enhancement.

But changing the Code Style settings needs a restart to take effect, because the generated source is cached.

Pilchie commented 7 years ago

Can you dig in - there seems to be something up with the use framework types/use predefined types option serialization.

yume-chan commented 7 years ago

I believe it's caused by cache. I tried:

  1. Hit F12 on a symbol to generate Metadata As Source.
  2. Locate the generated file, delete it.
  3. Edit Code Style settings.
  4. Hit F12 on the same symbol again to re-generate the source file.

Now Visual Studio will notify you the file is changed and the new generated file will use the new Code Style settings.

olegtk commented 7 years ago

This also affects LightBulb - for example "Generate local" now generates Object and String. Is it by design? If so - how to turn it off? I don't really like it.

jasonmalinowski commented 7 years ago

@olegtk It affects everything, more or less. Option should be changed here:

image

olegtk commented 7 years ago

So this is by design and we should just update our tests, right?

jasonmalinowski commented 7 years ago

@olegtk: no, this is a bug. (That's why this bug is open on me. :smile:)

jmarolf commented 7 years ago

metadata as source respects the option, but any already generated files are not re-generated when you change options. I'll use this bug to track fixing the metadata as source service to delete old generated files once the option is changed.

davkean commented 7 years ago

@jmarolf This was tracking that default changed.

Pilchie commented 7 years ago

That was fixed by https://github.com/dotnet/roslyn/pull/16373. Keeping this to track refreshing when options change.