Skip to content

Remove CS1701 and CS1702 warnings#66313

Draft
Youssef1313 wants to merge 2 commits into
dotnet:mainfrom
Youssef1313:remove-cs1701-cs1702-19640
Draft

Remove CS1701 and CS1702 warnings#66313
Youssef1313 wants to merge 2 commits into
dotnet:mainfrom
Youssef1313:remove-cs1701-cs1702-19640

Conversation

@Youssef1313

Copy link
Copy Markdown
Member

Very quick PR to fix #19640

@Youssef1313 Youssef1313 requested a review from a team as a code owner January 8, 2023 13:57
@ghost ghost added Area-Compilers Community The pull request was submitted by a contributor who is not a Microsoft employee. labels Jan 8, 2023
@Youssef1313 Youssef1313 marked this pull request as draft January 8, 2023 14:24
@Youssef1313

Copy link
Copy Markdown
Member Author

Draft for now. I'll debug the failing tests later :(
I'm okay in case someone wanted to complete this before me.

@AlekseyTs

Copy link
Copy Markdown
Contributor

Are all use-site diagnostics on symbols errors now? As in VB. If so, we probably should rename all relevant APIs that use "UseSiteDiagnostic" to "UseSiteError" to reflect the fact. Some checks for use-site errors (vs. warnings), if any, could be simplified as well. Also, we should see if calculation/merging of use-site diagnostics could be optimized/simplified (get out early, etc.) now.

@Youssef1313

Youssef1313 commented Jan 17, 2023

Copy link
Copy Markdown
Member Author

@AlekseyTs Could this be done in a separate follow-up PR (and open an issue to track that)?

@Youssef1313 Youssef1313 marked this pull request as ready for review January 17, 2023 20:19
@jcouv jcouv requested a review from AlekseyTs February 3, 2023 00:53
@AlekseyTs

AlekseyTs commented Feb 3, 2023

Copy link
Copy Markdown
Contributor

Could this be done in a separate follow-up PR (and open an issue to track that)?

I think that if we want to address the issue, we should do that without any need for an additional follow up. I do not see any urgency in stopping reporting the warnings. If we think that the issue is worth addressing, we should do that in its entirety.

@Youssef1313

Copy link
Copy Markdown
Member Author

@AlekseyTs I took a look

nullabilityDiagnosticsBuilderOpt.Add(new TypeParameterDiagnosticInfo(typeParameter, new UseSiteInfo<AssemblySymbol>(new CSDiagnosticInfo(ErrorCode.WRN_NullabilityMismatchInTypeParameterNotNullConstraint, containingSymbol.ConstructedFrom(), typeParameter, typeArgument))));
}
if (typeParameter.HasReferenceTypeConstraint &&
typeParameter.ReferenceTypeConstraintIsNullable == false &&
typeArgument.GetValueNullableAnnotation().IsAnnotated())
{
nullabilityDiagnosticsBuilderOpt.Add(new TypeParameterDiagnosticInfo(typeParameter, new UseSiteInfo<AssemblySymbol>(new CSDiagnosticInfo(ErrorCode.WRN_NullabilityMismatchInTypeParameterReferenceTypeConstraint, containingSymbol.ConstructedFrom(), typeParameter, typeArgument))));

and if I understand correctly, we can't get simplify anything here. Am I correct?

@AlekseyTs

Copy link
Copy Markdown
Contributor

and if I understand correctly, we can't get simplify anything here. Am I correct?

Are all use-site diagnostics on symbols errors now? As in VB.

I am primarily referring to the following APIs on Symbol:

        /// <summary>
        /// True if the symbol has a use-site diagnostic with error severity.
        /// </summary>
        internal bool HasUseSiteError
        {
            get
            {
                var info = GetUseSiteInfo();
                return info.DiagnosticInfo?.Severity == DiagnosticSeverity.Error;
            }
        }

        /// <summary>
        /// Returns diagnostic info that should be reported at the use site of the symbol, or default if there is none.
        /// </summary>
        internal virtual UseSiteInfo<AssemblySymbol> GetUseSiteInfo()
        {
            return default;
        }

By contrast VB has only:

        ''' <summary>
        ''' Returns dependencies and an error info for an error, if any, that should be reported at the use site of the symbol.
        ''' </summary>
        Friend Overridable Function GetUseSiteInfo() As UseSiteInfo(Of AssemblySymbol)
            Return Nothing
        End Function

If so, we probably should rename all relevant APIs that use "UseSiteDiagnostic" to "UseSiteError" to reflect the fact.

I was referring to legacy names for the APIs. So, I withdraw this suggestion.

Some checks for use-site errors (vs. warnings), if any, could be simplified as well.

Given the example where nullable warnings are added to the UseSiteInfo, we cannot make a general assumption that UseSiteInfo doesn't contain a warning. But it might be a valid assumption when we get it from symbol.

Also, we should see if calculation/merging of use-site diagnostics could be optimized/simplified (get out early, etc.) now.

I am primarily referring to the way we calculate value returned by Symbol.GetUseSiteInfo API. It is quite possible that there is nothing to optimize there, but it is worth checking, I think.


// TODO (tomat): we should display paths rather than names "refV1" and "C"

testRefV1.VerifyDiagnostics(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

VerifyDiagnostics

It doesn't feel like simply removing the verification of diagnostics is appropriate. I think at least we should verify that there is no diagnostics.


// TODO (tomat): we should display paths rather than names "RefLibV2" and "Lib"

main13.VerifyDiagnostics(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

VerifyDiagnostics

According to the comment above, it looks like the goal of the test was to verify that: "higher version should be preferred over lower version regardless of the order of the references". It also looks like the fact was verified indirectly by checking diagnostics. If we no longer can rely on this approach, we should find a different way to verify the outcome. It feels like we might want other tests that primarily were verifying presence of the warnings (at least all tests in this file) be adjusted in a similar way.

@jcouv

jcouv commented May 10, 2023

Copy link
Copy Markdown
Member

Marking PR as draft for now, to make room in our review queue. Please undraft when ready for another look. Thanks

@jcouv jcouv marked this pull request as draft May 10, 2023 20:35
xparadoxical added a commit to xparadoxical/gd-apis that referenced this pull request Dec 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Compilers Community The pull request was submitted by a contributor who is not a Microsoft employee.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Warnings CS1701 and CS1702 should be removed

3 participants