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

Speculative semantic model - create child member models for attributes and parameter default values. #64634

Merged
merged 5 commits into from
Oct 14, 2022

Conversation

AlekseyTs
Copy link
Contributor

Fixes #60801.
Fixes #24135.

This could occur when member semantic models were used to support/represent speculative semantic models.
This change gets us one step closer to addressing dotnet#60801.
…for attributes and parameter default values.

Fixes dotnet#60801.
Fixes dotnet#24135.
@CyrusNajmabadi
Copy link
Member

@jasonmalinowski anything in particular you wanted me to hone in on? Overall this looks fine to me :)

@jasonmalinowski
Copy link
Member

@CyrusNajmabadi No; this needed some IDE reviewer and you seemed like a good choice.

@CyrusNajmabadi
Copy link
Member

Gotcha. LGTM.

@AlekseyTs
Copy link
Contributor Author

@jcouv, @dotnet/roslyn-compiler For the second review.

@jcouv jcouv self-assigned this Oct 13, 2022
@AlekseyTs
Copy link
Contributor Author

@jcouv, @dotnet/roslyn-compiler For the second review.

using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.CSharp
{
Copy link
Member

@jcouv jcouv Oct 13, 2022

Choose a reason for hiding this comment

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

Consider adding xml doc.
nit: extra blank line below #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Consider adding xml doc.

I think the name is descriptive enough and captures everything that the doc comment would say.

namespace Microsoft.CodeAnalysis.CSharp
{
/// <summary>
/// Instances of this <see cref="SemanticModel"/> can be exposed to external consumers.
Copy link
Member

@jcouv jcouv Oct 13, 2022

Choose a reason for hiding this comment

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

Do we have a comment somewhere explaining why some instances should not be exposed to external customers? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we have a comment somewhere explaining why some instances should not be exposed to external customers?

This would violate the design.

Copy link
Member

Choose a reason for hiding this comment

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

I didn't follow how having a comment (I'm not talking about xml doc) would violate the design.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't follow how having a comment (I'm not talking about xml doc) would violate the design.

Sorry for the confusion. I was not referring to having a comment, but to exposing other instances to external consumers. Doing that would violate the design.

(binder: containing.GetEnclosingBinder(attribute.SpanStart), model: containing));
}

private MemberSemanticModel GetOrAddModelForParameter(SyntaxNode node, MemberSemanticModel containing, ParameterSyntax paramDecl)
Copy link
Member

@jcouv jcouv Oct 13, 2022

Choose a reason for hiding this comment

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

This seem very close or duplicated from SyntaxTreeSemanticModel.GetOrAddModelForParameter. Could we factorize? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could we factorize?

I considered that, but didn't think the refactoring worth the trouble.

_parentSemanticModel = parentSemanticModel;
_position = position;
_parentSnapshotManagerOpt = snapshotManagerOpt;
_memberModel = null!;
Copy link
Member

@jcouv jcouv Oct 13, 2022

Choose a reason for hiding this comment

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

How is this safe? Never mind, this ctor is private, and other constructors that depend on it make sure to initialize _memberModel. #Closed

Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

LGTM Thanks (iteration 4) with some minor comments/questions

@AlekseyTs AlekseyTs merged commit c12de00 into dotnet:main Oct 14, 2022
@ghost ghost added this to the Next milestone Oct 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants