Skip to content

Annotate more public syntax APIs#44266

Merged
jcouv merged 9 commits intodotnet:masterfrom
jcouv:annotate-more6
Jun 23, 2020
Merged

Annotate more public syntax APIs#44266
jcouv merged 9 commits intodotnet:masterfrom
jcouv:annotate-more6

Conversation

@jcouv
Copy link
Member

@jcouv jcouv commented May 14, 2020

No description provided.

@jcouv jcouv added Area-Compilers Concept-Null Annotations The issue involves annotating an API for nullable reference types labels May 14, 2020
@jcouv jcouv self-assigned this May 14, 2020
@jcouv jcouv marked this pull request as ready for review May 15, 2020 18:06
@jcouv jcouv requested review from a team as code owners May 15, 2020 18:06
@333fred
Copy link
Member

333fred commented May 19, 2020

Done review pass (commit 2) #Resolved

@jcouv jcouv requested a review from 333fred May 21, 2020 18:29
@jcouv
Copy link
Member Author

jcouv commented May 26, 2020

@333fred Please take another look when you get a chance. 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.

LGTM (commit 3)

@jcouv
Copy link
Member Author

jcouv commented May 27, 2020

Thanks Fred!

@dotnet/roslyn-compiler for a second review. Cheers

/// The value for a non-array constant.
/// </summary>
public object? Value
public object Value
Copy link
Contributor

@cston cston Jun 17, 2020

Choose a reason for hiding this comment

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

public object Value [](start = 8, length = 19)

Isn't this null for the constant null? #Closed

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks. I'd misread the assertion in constructor.


In reply to: 441893234 [](ancestors = 441893234)

@cston
Copy link
Contributor

cston commented Jun 17, 2020

    internal object ValueInternal

object?? #Closed


Refers to: src/Compilers/Core/Portable/Symbols/TypedConstant.cs:93 in d801f2a. [](commit_id = d801f2a, deletion_comment = False)

Debug.Assert(lambdaBody.Parent is object);
var lambda = lambdaBody.Parent;
if (lambda.Kind() == SyntaxKind.ArrowExpressionClause)
if (lambda.IsKind(SyntaxKind.ArrowExpressionClause))
Copy link
Contributor

@cston cston Jun 18, 2020

Choose a reason for hiding this comment

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

IsKind( [](start = 23, length = 7)

Just curious - why change these? #Resolved

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 lambda.Kind() on line 63 would warn. Then I think I just aligned the check on line 57 for stylistic consistency.


In reply to: 441899787 [](ancestors = 441899787)

else
{
visited = this.VisitListElement((TNode)item.AsNode());
visited = this.VisitListElement((TNode?)item.AsNode());
Copy link
Contributor

@cston cston Jun 18, 2020

Choose a reason for hiding this comment

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

(TNode?)item.AsNode() [](start = 60, length = 21)

Can we use node here? #Closed

}

internal bool TryDecodeValue<T>(SpecialType specialType, [MaybeNull][NotNullWhen(returnValue: true)] out T value)
internal bool TryDecodeValue<T>(SpecialType specialType, [MaybeNull][NotNullWhen(true)] out T value)
Copy link
Contributor

@cston cston Jun 19, 2020

Choose a reason for hiding this comment

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

[NotNullWhen(true)] [](start = 76, length = 19)

What if value == null? #Closed

if (_type.SpecialType == specialType || (_type.TypeKind == TypeKind.Enum && specialType == SpecialType.System_Enum))
{
value = (T)_value!;
Debug.Assert(_value is object);
Copy link
Contributor

@cston cston Jun 19, 2020

Choose a reason for hiding this comment

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

Debug.Assert(_value is object); [](start = 16, length = 31)

Don't we get here with a constant null? #Closed


Debug.Assert(args.Length <= 2);
message = (string)args[0].ValueInternal;
Debug.Assert(args[0].ValueInternal is object);
Copy link
Contributor

@cston cston Jun 19, 2020

Choose a reason for hiding this comment

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

Debug.Assert(args[0].ValueInternal is object); [](start = 16, length = 46)

Could the value be [Obsolete(null)]? #Closed


message = (string)args[0].ValueInternal;
isError = ((int)args[1].ValueInternal == 1);
Debug.Assert(args[0].ValueInternal is object);
Copy link
Contributor

@cston cston Jun 19, 2020

Choose a reason for hiding this comment

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

Debug.Assert(args[0].ValueInternal is object) [](start = 16, length = 45)

Could the value be [Deprecated(null, ...)]? #Closed

{
/// <summary>
/// Returns the System.String that represents the current TypedConstant.
/// For testing and debugging only
Copy link
Contributor

@cston cston Jun 19, 2020

Choose a reason for hiding this comment

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

For testing and debugging only [](start = 12, length = 30)

This method is part of the public API so I don't think we can state how this method is used. #Closed

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks


In reply to: 443063564 [](ancestors = 443063564)


// Unable to decode the enum constant, just display the integral value
return constant.ValueInternal.ToString();
Debug.Assert(constant.ValueInternal is object);
Copy link
Contributor

@cston cston Jun 19, 2020

Choose a reason for hiding this comment

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

Debug.Assert(constant.ValueInternal is object) [](start = 12, length = 46)

Why assert rather than using !? #ByDesign

Copy link
Member Author

Choose a reason for hiding this comment

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

Because this is the result of a check in a calling method (if (constant.IsNull) in ToCSharpString), but not in the present method.


In reply to: 443063994 [](ancestors = 443063994)


// Unable to decode the enum constant, just display the integral value
return constant.ValueInternal.ToString();
Debug.Assert(constant.ValueInternal is object);
Copy link
Contributor

@cston cston Jun 19, 2020

Choose a reason for hiding this comment

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

Debug.Assert(constant.ValueInternal is object); [](start = 12, length = 47)

Why assert rather than using !? #ByDesign

Copy link
Member Author

Choose a reason for hiding this comment

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

Same rationale


In reply to: 443064067 [](ancestors = 443064067)

message = (string)args[0].ValueInternal;
isError = ((int)args[1].ValueInternal == 1);
Debug.Assert(args[1].ValueInternal is object);
message = (string?)args[0].ValueInternal!;
Copy link
Contributor

@cston cston Jun 20, 2020

Choose a reason for hiding this comment

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

! [](start = 56, length = 1)

! is incorrect. #Closed

/// </param>
/// <returns>Normalized XML document file path or null if not found.</returns>
public override string? ResolveReference(string path, string? baseFilePath)
public override string? ResolveReference(string? path, string? baseFilePath)
Copy link
Contributor

@cston cston Jun 20, 2020

Choose a reason for hiding this comment

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

string? path [](start = 49, length = 12)

Why is path optional? It looks like the uses of path support null values, but allowing null seems incorrect given the parameter description where it is a path to a source file. #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm trying to capture/document the existing behavior of this method.
The test I added does exercise this path. I can adjust the caller instead (don't call if path is null), but result is same.


In reply to: 443154834 [](ancestors = 443154834)

/// <param name="baseFilePath">Path of the source file that contains the <paramref name="path"/> (may also be relative), or null if not available.</param>
/// <returns>Path to the XML artifact, or null if the file can't be resolved.</returns>
public abstract string? ResolveReference(string path, string? baseFilePath);
public abstract string? ResolveReference(string? path, string? baseFilePath);
Copy link
Contributor

@cston cston Jun 20, 2020

Choose a reason for hiding this comment

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

string? path [](start = 49, length = 12)

Why is path optional? #Resolved

@jcouv jcouv merged commit 9a658fa into dotnet:master Jun 23, 2020
@ghost ghost added this to the Next milestone Jun 23, 2020
@jcouv jcouv deleted the annotate-more6 branch June 23, 2020 23:33
@dibarbet dibarbet modified the milestones: Next, 16.7.P4 Jun 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Compilers Concept-Null Annotations The issue involves annotating an API for nullable reference types

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants