Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Targeting IDE projects to .NET 6 #66655

Merged
merged 11 commits into from
Feb 9, 2023
Merged

Targeting IDE projects to .NET 6 #66655

merged 11 commits into from
Feb 9, 2023

Conversation

genlu
Copy link
Member

@genlu genlu commented Feb 1, 2023

@dotnet/roslyn-ide @dotnet/roslyn-compiler Please take a look. Thanks

@genlu genlu requested review from a team as code owners February 1, 2023 21:32
@@ -257,7 +257,7 @@ internal sealed class PdbSourceDocumentMetadataAsSourceFileProvider : IMetadataA
// to the document passed in, which we just use the first document for.
// TODO: Support results from multiple source files: https://github.com/dotnet/roslyn/issues/55834
var firstDocumentFilePath = sourceFileInfos[0]!.FilePath;
var firstDocument = navigateProject.Documents.FirstOrDefault(d => d.FilePath?.Equals(firstDocumentFilePath, StringComparison.OrdinalIgnoreCase) ?? false);
var firstDocument = navigateProject.Documents.First(d => d.FilePath?.Equals(firstDocumentFilePath, StringComparison.OrdinalIgnoreCase) ?? false);
Copy link
Member Author

@genlu genlu Feb 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidwengier Does this look right to you?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd like this answered as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine to me. We fill that project with documents from the sourceFileInfos, and check that its got files in it on line 243, so if this every fails, we would want a PRISM bug to tell us.

@@ -89,7 +89,7 @@ private static string GetIndentation(Document document, SyntaxNode node, SyntaxF
protected override async Task<Document> AddIndentationToDocumentAsync(Document document, int position, ISyntaxFacts syntaxFacts, CancellationToken cancellationToken)
{
var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
var snippet = root.GetAnnotatedNodes(_findSnippetAnnotation).FirstOrDefault();
var snippet = root.GetAnnotatedNodes(_findSnippetAnnotation).First();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI @akhera99 for snippet related change

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't trust this at all. @akhera99 how do you know you will absolutely find the node here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured it would given that, when we annotate the added snippet, we throw if the added snippet can't be found. I think it's safer to keep it as FirstOrDefault, but I believe we bail out earlier in case it's not found.

@@ -5,7 +5,7 @@
// Copied from:
// https://github.com/dotnet/runtime/blob/fdd104ec5e1d0d2aa24a6723995a98d0124f724b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/CompilerFeatureRequiredAttribute.cs

#if !NET6_0_OR_GREATER
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would #if NETSTANDARD be better, so that it is not updated every time we bump version?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems this type is not in .net 6 either, only in net 7

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's the runtime PR addign those types
dotnet/runtime#64287

@@ -5,7 +5,7 @@
// Copied from:
// https://github.com/dotnet/runtime/blob/fdd104ec5e1d0d2aa24a6723995a98d0124f724b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RequiredMemberAttribute.cs

#if !NET6_0_OR_GREATER
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would #if NETSTANDARD be better, so that it is not updated every time we bump version?

@@ -5,7 +5,7 @@
// Copied from:
// https://github.com/dotnet/runtime/blob/fdd104ec5e1d0d2aa24a6723995a98d0124f724b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/SetsRequiredMembersAttribute.cs

#if !NET6_0_OR_GREATER
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would #if NETSTANDARD be better, so that it is not updated every time we bump version?

@@ -28,7 +29,7 @@ public AnalyzerSettingsProvider(string fileName, AnalyzerSettingsUpdater setting

protected override void UpdateOptions(TieredAnalyzerConfigOptions options, ImmutableArray<Project> projectsInScope)
{
var analyzerReferences = projectsInScope.SelectMany(p => p.AnalyzerReferences).DistinctBy(a => a.Id).ToImmutableArray();
var analyzerReferences = RoslynEnumerableExtensions.DistinctBy(projectsInScope.SelectMany(p => p.AnalyzerReferences), a => a.Id).ToImmutableArray();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actually need the extension method?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can unify them to BCL implementation, but I'd keep the original logic in this PR

@@ -5,7 +5,7 @@
// Copied from:
// https://github.com/dotnet/runtime/blob/fdd104ec5e1d0d2aa24a6723995a98d0124f724b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/CompilerFeatureRequiredAttribute.cs

#if !NET6_0_OR_GREATER
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to change this directive (now or in the future). net7.0 falls under NET6_0_OR_GREATER.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the problem is we are compiled for .NET6, which would exclude this from code, but the type only available in .NET7

@@ -2,7 +2,7 @@
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;netcoreapp3.1;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks>
Copy link
Member

@sharwell sharwell Feb 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ Is there a need to change this? This project is usable outside Roslyn. I'd prefer to only increase the version if the new version is providing some new feature/ability.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason for this is I'm also gonna bump our BCL reference to 7, which would cause error for project targeting 3.1

packages/system.text.encoding.codepages/7.0.0/buildTransitive/netcoreapp2.0/System.Text.Encoding.CodePages.targets(4,5): error : (NETCORE_ENGINEERING_TELEMETRY=Build) System.Text.Encoding.CodePages 7.0.0 doesn't support netcoreapp3.1 and has not been tested with it. Consider upgrading your TargetFramework to net6.0 or later. You may also set true in the project file to ignore this warning and attempt to run in this unsupported configuration at your own risk.

Copy link
Member

@tmat tmat Feb 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may also set true in the project file to ignore this warning and attempt to run in this unsupported configuration at your own risk.

Can we set that something to true to ignore the error? This is a source package anyways, so it shouldn't matter.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I just wasn't aware of a reason that warrants suppressing the warning.

…ion.cs

Co-authored-by: Sam Harwell <sam@tunnelvisionlabs.com>
@genlu
Copy link
Member Author

genlu commented Feb 7, 2023

@jaredpar @jcouv @dotnet/roslyn-compiler Please take a look. Thanks!

Copy link
Member

@333fred 333fred left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compiler changes LGTM.

@genlu
Copy link
Member Author

genlu commented Feb 8, 2023

@CyrusNajmabadi @akhera99 Could you take another look please? Thanks!

@akhera99
Copy link
Member

akhera99 commented Feb 8, 2023

Snippet changes look good

Copy link
Member

@cston cston left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compiler changes LGTM.

Copy link
Member

@CyrusNajmabadi CyrusNajmabadi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

signing off on most of the IDE changes. but there are outstanding questions for DavidW and JasonMal that need to be answered. Thanks :)

@genlu genlu enabled auto-merge (squash) February 9, 2023 00:28
@genlu genlu merged commit 65866e2 into dotnet:main Feb 9, 2023
@ghost ghost added this to the Next milestone Feb 9, 2023
@CyrusNajmabadi
Copy link
Member

but there are outstanding questions for DavidW and JasonMal that need to be answered.

:-/

@sharwell
Copy link
Member

sharwell commented Feb 9, 2023

@CyrusNajmabadi the issues that led to those questions were reverted

@genlu genlu deleted the TargetNet6 branch February 9, 2023 18:39
@davidwengier
Copy link
Contributor

I answered mine :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants