Support multi-target framework intellisense #7848
Conversation
var copy = new DotNetProjectConfiguration (name, platform, framework); | ||
copy.CopyFrom (itemConfiguration); | ||
|
||
return copy; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is weird. A selector is supposed to return one of the configurations in the provided target, not create a new one. Why is this required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly this is a bit of a hack which I do not like.
The framework information is needed when running an MSBuild target so I was trying to get this to the DotNetProject when it runs MSBuild to get references etc without adding an extra framework parameter to each method. Currently the active selector in the workbench has no knowledge of the framework so the type system service is cheating here and creates another selector and sets the framework it wants.
} | ||
} | ||
|
||
public string Platform { | ||
get { return platform ?? string.Empty; } | ||
} | ||
|
||
public string Framework { | ||
get { return framework; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the concept of framework is specific to .net? in that case this should be part of DotNetProjectConfiguration.
8758e71
to
e756d6b
Compare
ee4183b
to
04e2798
Compare
501ba8d
to
9dc8ae5
Compare
main/src/addins/CSharpBinding/MonoDevelop.CSharp/CSharpPathedDocumentExtension.cs
Outdated
Show resolved
Hide resolved
...addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore.NodeBuilders/DependenciesNodeBuilder.cs
Outdated
Show resolved
Hide resolved
main/src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProject.cs
Outdated
Show resolved
Hide resolved
main/src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProject.cs
Outdated
Show resolved
Hide resolved
var traversedProjects = new HashSet<string> (StringComparer.OrdinalIgnoreCase); | ||
traversedProjects.Add (Project.ItemId); | ||
string include = MSBuildProjectService.ToMSBuildPath (Project.ItemDirectory, fileName); | ||
var globItems = Project.MSBuildProject.FindGlobItemsIncludingFile (include).ToList (); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can do:
var globItems = Project.MSBuildProject.FindGlobItemsIncludingFile (include).ToList (); | |
var globItems = Project.MSBuildProject.FindGlobItemsIncludingFile (include).SingleOrDefault (); |
To avoid matching all the items.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I can change this. There may not be any matches - but could use FirstOrDefault instead. If there is more than one match we do not know what to return so fallback to asking the project for its default build action. Although not sure I have seen any examples of multiple matches here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, was just trying to avoid a new collection allocation, as it seems redundant.
main/src/core/MonoDevelop.Core/MonoDevelop.Projects/SdkProjectExtension.cs
Outdated
Show resolved
Hide resolved
LGTM! |
...ins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore.Gui/DotNetCoreRuntimeOptionsPanelWidget.cs
Show resolved
Hide resolved
main/src/core/MonoDevelop.Core/MonoDevelop.Core.Execution/TargetFrameworkExecutionTarget.cs
Show resolved
Hide resolved
main/src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProject.cs
Outdated
Show resolved
Hide resolved
main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels/RuntimeOptionsPanel.cs
Outdated
Show resolved
Hide resolved
.../MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopWorkspace.MetadataReferenceHandler.cs
Show resolved
Hide resolved
main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopWorkspace.ProjectDataMap.cs
Outdated
Show resolved
Hide resolved
main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopWorkspace.ProjectDataMap.cs
Outdated
Show resolved
Hide resolved
When a project file is edited in the text editor and saved, triggering a reload, the open documents registered with the type system would not update their owner. This would happen if the document was referenced by more than one text editor extension - the owner changing would not remove the open document when the DocumentRegistration class was disposed since another reference kept it alive. This resulted in the C# path bar not being updated for multi-target framework projects when the frameworks were changed and the project file saved. To fix this the owner of the open document is updated if it is not null and does not match the original owner. This allows the type system's TryRegisterOpenDocument to update the Roslyn workspace and trigger the workspace changed event used by the C# path bar.
These get used fairly frequently by the type system service and without being cached resulted in the MSBuild properties for the project being evaluated each time.
Renamed the property from Framework to FrameworkShortName since there is an existing TargetFramework property. Make FrameworkShortName property internal. The TargetFramework property is public and can be used instead.
Refactored the dependency node tests so they test the node builders themselves. Previously the data object classes were being tested. This is in preparation for new tests for multi-target projects.
Previously multi-target framework projects would show the framework nodes under Dependencies - NuGet and Dependencies - SDK. Now the framework nows appear directly under the Dependencies folder. Note that currently the Assemblies and Projects folders do not support multi-target frameworks and just show all assemblies and projects referenced directly in the project ignoring any conditions.
A different feature branch added TargetFrameworkShortName to the DotNetProjectConfiguration. Re-use the same property instead of having a different property for use with multi-target projects.
Update code after review. Seal class and implement IEquatable.
Remove local variable in node builder after code review. The local variable is not needed in the method.
Avoid allocations by using a value tuple as the key for the framework specific configurations. DotNetProject's OnClearCachedData does not need to be async. Specify list length when creating the execution target list since it is known.
Fixed some code duplication. Make some fields readonly. Specify TaskScheduler for ContinueWith. Avoid use of LINQ.
The Framework icon is used as the image for an execution target if it is a framework belonging to a multi-target framework project.
The type system service was only checking the file extension not the build action. Fixes VSTS #843603 - Files with build action 'None' are still used by Intellisense
Project.CreateProjectInstanceForConfigurationAsync does not need to be protected since it is only used with MonoDevelop.Core.
6fd0ba0
to
ca48c96
Compare
Took it for a spin, works properly from what I've tested! Nice work! |
UI test for project system is from Nuget changes and is fixed in master. Neither failings are related as far as we know. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
works good
Type system service now supports multi-target frameworks.
Path bar supports multi-target framework selection.
Framework execution targets shown in main toolbar.
Fixes VSTS #572311 - Multi-framework support in Roslyn workspace
Fixes VSTS #572342 - Support picking target framework for intellisense
Fixes VSTS #937105 Show (Multiple TargetFrameworks) in project options
Fixes VSTS #572309 - Execution target support for multi-framework projects
Fixes VSTS #935387 - System.NullReferenceException exception in MonoDevelop.Projects.DotNetProject.d__XXX.MoveNext() - Transitive references null reference exception fixed since this code no longer existx.
Fixes VSTS #572307 - Ensure navigation/refactoring operations on multi-frameworks projects are coalesced
Fixes VSTS #843603 Files with build action 'None' are still used by Intellisense
- Do not want ASP.NET Core project extension checking for certificate status when .NET Framework is the execution target.