Project-system: File context drop down聽doesn't stick with multi-targeting

Created on 21 Dec 2016  路  26Comments  路  Source: dotnet/project-system

When I try to change the context of a file open in the IDE, after changing the drop down, it immediately reverts.

To repro:

Open up Observable.Queryable.cs聽(in ..System.Reactive.ProvidersReactiveLinq).聽Now try to change the context of the file in the upper-left of the code window.

This happened聽with the preview2 tooling in VS 2015. My theory is that it happens with files that are outside the root level of the csproj.

Bug

All 26 comments

We're still not populating IsInCurrentContext - so that's probably related. Are you saying that it works for you for files inside of the project folder in above project?

Yes, that appears to be the case. If I add a blank file, Class1.cs to the聽root of the project, then the聽context for that file appears to stick.

Dave, we are populating IsInCurrentContext, so this is expected to work.

There is a known Roslyn bug due to which closing and opening any source file causes context changes to not be respected henceforth. @onovotny are you by any chance closing the file, re-opening and then trying the context switch?

Nope, just opening it once.

Sent from my Windows 10 phone

From: Manish Vasaninotifications@github.com
Sent: Tuesday, December 20, 2016 11:00 PM
To: dotnet/roslyn-project-systemroslyn-project-system@noreply.github.com
Cc: Oren Novotnyoren@novotny.org; Mentionmention@noreply.github.com
Subject: Re: [dotnet/roslyn-project-system] File context drop down doesn't stick with multi-targeting (#1013)

There is a known Roslyn bug due to which closing and opening any source file causes context changes to not be respected henceforth. @onovotnyhttps://github.com/onovotny are you by any chance closing the file, re-opening and then trying the context switch?

-
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com/dotnet/roslyn-project-system/issues/1013#issuecomment-268429853, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ABXHVPU_xfFrZq2dHBBkZLLwPRM1chJoks5rKKRngaJpZM4LSgkE.

@onovotny I tried this on current bits and it doesn't repro.

I don't know what/if we fixed anything around this. Can you try in the build you installed last week and see if you can repro the same issue?

I did find https://github.com/dotnet/roslyn-project-system/issues/1327 though, not sure what's going on there.

That project isn't repro'ing anymore but I have one that still does with those bits:

https://github.com/onovotny/microsoft-authentication-library-for-dotnet

Clone that and checkout the simplify-structure branch. With聽last week's build, if I open in VS, go to srcMicrosoft.Identity.Client then into the ..MSAL.Common folder and open MsalEventSource.cs, it opens as netstandard1.3 context. In the drop down, if I change to聽either the win81 or net45 context, it does not stick.

Thanks, will take a look at it.

Tried this - it's ending up in misc files in my case. Debugging.

Okay, looks like all the configurations are failing to evaluate due to the missing targets:

CPS Error: 0 : Source 0 'Microsoft.VisualStudio.ProjectSystem.DataflowExtensions+SafeSourceBlockWrapper`2[Microsoft.VisualStudio.ProjectSystem.IProjectVersionedValue`1[Microsoft.VisualStudio.ProjectSystem.IProjectCapabilitiesSnapshot],Microsoft.VisualStudio.ProjectSystem.IProjectVersionedValue`1[Microsoft.VisualStudio.ProjectSystem.IProjectCapabilitiesSnapshot]]' of SyncLinkTo failed.:System.AggregateException: One or more errors occurred. ---> Microsoft.Build.Exceptions.InvalidProjectFileException: The imported project "C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.CSharp.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.  C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.targets
   at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(String errorSubCategoryResourceName, IElementLocation elementLocation, String resourceName, Object[] args)
   at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(IElementLocation elementLocation, String resourceName, Object arg0)
   at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImportsFromUnescapedImportExpression(String directoryOfImportingFile, ProjectImportElement importElement, String unescapedExpression, Boolean throwOnFileNotExistsError, List`1& imports)
   at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImportsFromUnescapedImportExpressionConditioned(String directoryOfImportingFile, ProjectImportElement importElement, String unescapedExpression, List`1& projects, Boolean throwOnFileNotExistsError)
   at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImports(String directoryOfImportingFile, ProjectImportElement importElement)
   at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
   at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
   at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
   at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
   at Microsoft.Build.Evaluation.Evaluator`4.Evaluate()
   at Microsoft.Build.Evaluation.Evaluator`4.Evaluate(IEvaluatorData`4 data, ProjectRootElement root, ProjectLoadSettings loadSettings, Int32 maxNodeCount, PropertyDictionary`1 environmentProperties, ILoggingService loggingService, IItemFactory`2 itemFactory, IToolsetProvider toolsetProvider, ProjectRootElementCache projectRootElementCache, BuildEventContext buildEventContext, ProjectInstance projectInstanceIfAnyForDebuggerOnly)
   at Microsoft.Build.Evaluation.Project.Reevaluate(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings)
   at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings)
   at Microsoft.Build.Evaluation.Project.Initialize(IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectLoadSettings loadSettings)
   at Microsoft.Build.Evaluation.Project..ctor(ProjectRootElement xml, IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings)
   at Microsoft.Build.Evaluation.Project..ctor(ProjectRootElement xml, IDictionary`2 globalProperties, String toolsVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings)
   at Microsoft.VisualStudio.ProjectSystem.ConfiguredProjectImpl.<>c__DisplayClass90_0.<<InitializeAsync>b__3>d.MoveNext() in E:\CPS\src\Microsoft.VisualStudio.ProjectSystem.Implementation\ConfiguredProjectImpl.cs:line 501
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Threading.AsyncLazy`1.<>c__DisplayClass13_1.<<GetValueAsync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Threading.AsyncReaderWriterResourceLock`2.Helper.<GetResourceAsync>d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Microsoft.VisualStudio.ProjectSystem.Designers.ProjectSnapshotService.<GenerateProjectInstanceAsync>d__26.MoveNext() in E:\CPS\src\Microsoft.VisualStudio.ProjectSystem.Implementation\Designers\ProjectSnapshotService.cs:line 207

We're not logging/showing this anywhere. This explains why this ends up Misc - need to figure if this is the same cause for your repro.

@davkean that's a start,聽but def not what I saw :)

Can you install the Xamarin workload and then try again? It does seem like there should be a warning or something that tells the user what to do. Better yet, if this particular error can trigger the Xamarin workload install, that'd be great.

Looks like the original bug is caused by https://github.com/dotnet/roslyn/issues/5343. Leaving this around so that I can investigate the missing targets case.

In still see this in RC4 btw

Yes, it hasn't been fixed and has been pushed past RTM.

grr....ok

You can add comments to the original bug. :)

I'm also hitting this in MiniProfiler, seems to happen in specific #ifdef sections and whenever a .csproj is open for editing especially. It's extremely annoying and makes the editor useless if not working in the framework it decides to default to.

How long after RTM are we looking at a fix for this? If it's Update 1, that's going to be very painful.

I'm seeing this very frequently, note that the state in the bar is incorrect as well:
screen shot 2017-02-21 at 20 41 44
...and if I hit a letter (d):
screen shot 2017-02-21 at 20 41 53
Then the state is refreshed. Note that my screen is still grey and the IDE has changed target frameworks on me.

In a file that's entirely #if NET46, I keep getting kicking into netstandard. It's really quite infuriating. And it happens about once every 30-60 seconds. It makes the IDE nearly unusable. I've regressed to using VS Code to edit these files.

Please, prioritize this for a fix ASAP. It's maddeningly broken.

The above state is triggered after .csproj changes under some circumstances, I'm not sure what exactly. I was simply editing references to add a package on each TFM. Once done editing, a restart of VS gets it out of this state. So there is a way to restore usability, but it's still pretty high on the annoyance factor.

Seems like there is more than one issue here. I'll investigate it tonight. Nick, do you have a minimal repro?

@NickCraver I found 2 minimal repros where the navigation bar doesn't behave correctly on opening or adding a new source file: https://github.com/dotnet/roslyn-project-system/issues/1612 and https://github.com/dotnet/roslyn-project-system/issues/1613. Additionally, we have the Roslyn issue https://github.com/dotnet/roslyn/issues/5343 where the navigation bar stops working after closing and re-opening a source file.

@srivatsn - we should target https://github.com/dotnet/roslyn-project-system/issues/1612 and https://github.com/dotnet/roslyn-project-system/issues/1613 for 15.1

@Pilchie @dpoeschl - https://github.com/dotnet/roslyn/issues/5343 has got numerous feedback requests, and we should target it for 15.1.

Once the above issues are fixed, we can hand out the bits to the Nick and Oren for further round of testing.

@mavasani Thanks (sorry missed the first ping) - the issue I'm hitting is very inconsistent but does follow making .csproj changes. I'm not sure if it's references specifically, or just an overall artifact of the roundabout .csproj edit method currently in RC4 (with a separate file). You get the "do you want to reload these changes...?" style prompt, and later follows the inconsistent framework states.

Closing the .csproj tabs does not fix it. Restarting VS is the only fix I'm aware of, so at least there's some workaround in play. Happy to help test as always, including the advanced builds.

I have PRs out to fix #1612 and #1613: https://github.com/dotnet/roslyn-project-system/pull/1637 and https://github.com/dotnet/roslyn/pull/17424 respectively. We are going to do a bar check for these issues for 15.1

@NickCraver I will try to repro the edit csproj scenario now. Please do let me know if you can repro this consistently and have concrete repro steps.

I have another PR out to fix the Roslyn issue https://github.com/dotnet/roslyn/issues/5343, where navigation bar switch stopped working after closing and re-opening documents. I have done a bunch of testing with these 3 PRs applied locally and navigation bar seems to work fine for me for all known cases. I will keep bashing at it to identify any more issues.

All the 3 PRs I mentioned above have been merged into master branch of roslyn-project-system and roslyn repos respectively.

Was this page helpful?
0 / 5 - 0 ratings