Bug 57109 - No code completion for classes when EnableDefaultCompileItems set to false
Summary: No code completion for classes when EnableDefaultCompileItems set to false
Status: CONFIRMED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: .NET Core support ()
Version: 7.0 (VSforMac)
Hardware: PC Mac OS
: Normal normal
Target Milestone: Future Cycle (TBD)
Assignee: Matt Ward
URL:
Depends on:
Blocks:
 
Reported: 2017-06-02 14:47 UTC by Matt Ward
Modified: 2018-01-08 22:17 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 57109 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description Matt Ward 2017-06-02 14:47:22 UTC
https://developercommunity.visualstudio.com/content/problem/64181/vs-for-mac-cannot-handle-manually-included-source.html

To repro:

1) Create a new .NET Standard project.
2) Edit the .csproj so it has:

<EnableDefaultCompileItems>false</EnableDefaultCompileItems>

3) The Class1.cs file in the Solution window will be removed.
4) Add the Class1.cs file back by right clicking the project and selecting Add Files.
5) See the Class1.cs file is added into the .csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard1.4</TargetFramework>
    <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="Class1.cs" />
  </ItemGroup>
</Project>

6) The Class1.cs file should also be shown in the Solution window.
7) Type say 'using ' into the top of the Class1.cs file.

Expected result:

See code completion for usings.

Actual result:

See no code completion anywhere in the file. The type system seems to be unaware of the classes in the project.
Comment 1 Matt Ward 2017-06-07 09:50:37 UTC
The problem seems to be that when EnableDefaultCompileItems is set to false the EvaluatedItems for the project contains the Class1.cs file as both a None item and a Compile item. The TypeSystem calls Project.GetSourceFilesAsync which returns the None item first followed by the Compile item. The TypeSystem adds the None item to its list of documents and then when it tries to add the Compile item it finds the file already exists so ignores it. So the Class1.cs file is treated as a None item by the type system.
Comment 2 Matt Ward 2017-06-07 10:01:41 UTC
A workaround is to use EnableDefaultItems instead which disables all default items. This avoids the default None items.

  <PropertyGroup>
    <TargetFramework>netstandard1.6</TargetFramework>
    <EnableDefaultItems>false</EnableDefaultItems>
  </PropertyGroup>
Comment 3 Matt Ward 2017-06-07 10:14:50 UTC
This looks like a bug in the sdk targets. The Compile items should be removed from the None items if EnableDefaultCompileItems is false. There seems to have been a fix made for this but it was closed:

https://github.com/dotnet/sdk/pull/1163/files