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

Extensions refactor #10850

Merged
merged 12 commits into from
Sep 19, 2024
Merged

Extensions refactor #10850

merged 12 commits into from
Sep 19, 2024

Conversation

chsienki
Copy link
Contributor

@chsienki chsienki commented Sep 6, 2024

Deletes code that was duplicated across the MVC3/2/1 extensions.

I made changes in fairly small grouped commits, so commit-by-commit might be easier. Almost all of them are just deletes though, with the exception of 712bd0d which added a parameter to control the output for V1&2

At each commit I ran tests and verified everything was green. There is more code we can de-duplicate but the rest requires more involved parameters to control so I figured I would keep the diffs here dirt simple.

@chsienki chsienki added tech-debt area-compiler Umbrella for all compiler issues labels Sep 6, 2024
@chsienki chsienki requested a review from a team as a code owner September 6, 2024 22:03
@chsienki
Copy link
Contributor Author

chsienki commented Sep 6, 2024

@dotnet/roslyn-compiler for review please :)

Copy link
Member

@DustinCampbell DustinCampbell left a comment

Choose a reason for hiding this comment

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

Awesome!

Comment on lines -196 to +199
var irDocument = codeDocument.GetDocumentIntermediateNode();
irDocument.DocumentKind = MvcViewDocumentClassifierPass.MvcViewDocumentKind;
return irDocument;
return codeDocument.GetDocumentIntermediateNode();
Copy link
Member

Choose a reason for hiding this comment

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

Is this no longer needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The tests weren't registering the MvcViewDocumentClassifierPass so the document type wasn't set. I changed the tests to include that pass so there's no need to manually override it anymore.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the information!

Sigh... This sort of test infrastructure is odd to me. Why not just run the tests on the real thing instead of hacking and setting random properties to make it seem as if it's the real thing? I saw something very similar in tests when removing the CodeRenderingContext.Items property.

@chsienki
Copy link
Contributor Author

chsienki commented Sep 9, 2024

@dotnet/razor-compiler for a second review please :)

@@ -42,7 +42,7 @@ public void WriteInjectProperty(CodeRenderingContext context, InjectIntermediate
else if (!node.IsMalformed)
{
var property = $"public {node.TypeName} {node.MemberName} {{ get; private set; }}";
if (!context.Options.SuppressNullabilityEnforcement)
if (considerNullabilityEnforcement && !context.Options.SuppressNullabilityEnforcement)
Copy link
Member

Choose a reason for hiding this comment

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

Can't we set context.Options.SuppressNullabilityEnforcement in the tests where we need it instead of introducing a new test-only parameter?

Copy link
Contributor Author

@chsienki chsienki Sep 17, 2024

Choose a reason for hiding this comment

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

No, this isn't about testing, but actual implementation. We don't ever want to write out the nullability info for the older MVC versions. There probably isn't any harm in doing so, but I wanted to make sure the emitted code was exactly the same as part of this PR.

See here for where they are used in non-test code: 712bd0d#diff-156fa1883266f94c39e6b7474a75a11fc3c382ff439d8fedd22727f5a5b0c6faR23

Copy link
Member

@jjonescz jjonescz Sep 10, 2024

Choose a reason for hiding this comment

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

So we removed some Mvc.Version1_X and Mvc.Version2_X classes. Does the compiler now pick up Mvc (v3) equivalents instead? How does that work?

Copy link
Contributor Author

@chsienki chsienki Sep 17, 2024

Choose a reason for hiding this comment

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

Yes. They have the same names, and the previous V1/V2 classes were in 'deeper' namespaces. With those gone, the references now resolve to the 'shallower' namespace'd V3 versions.

@chsienki chsienki merged commit 0f60d02 into dotnet:main Sep 19, 2024
12 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-compiler Umbrella for all compiler issues tech-debt
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants