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

Emit attribute changes for parameters #54835

Merged
merged 18 commits into from
Jul 27, 2021

Conversation

davidwengier
Copy link
Contributor

Fixes #54777

This was a pain! In a way I'm glad I didn't do this while doing custom attributes because I probably would have gone crosseyed.

@davidwengier
Copy link
Contributor Author

Oh, as painful as some of this is, most of it is necessary for parameter renames anyway, so we get bang for our buck!

@davidwengier
Copy link
Contributor Author

/azp run

@davidwengier
Copy link
Contributor Author

The build errors don't match the file contents ¯\_(ツ)_/¯

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@tmat
Copy link
Member

tmat commented Jul 21, 2021

    protected override void PopulateEncLogTableRows(ImmutableArray<int> rowCounts)

Let's make PopulateEncTables virtual and PopulateEncLogTableRows and PopulateEncMapTableRows private non-virtual.

Then _customAttributeEncMapRows and _paramEncMapRows can be passed between these methods isntead of being fields defined on the writer.


Refers to: src/Compilers/Core/Portable/Emit/EditAndContinue/DeltaMetadataWriter.cs:782 in c13f258. [](commit_id = c13f258, deletion_comment = False)

Copy link
Member

@tmat tmat left a comment

Choose a reason for hiding this comment

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

🕐

@davidwengier davidwengier force-pushed the EnCEmitParametersOnMethodUpdate branch from c13f258 to 2dd3ad6 Compare July 23, 2021 04:16
@davidwengier
Copy link
Contributor Author

Tomas and I discussed offline and we decided to just have the compiler emit Param rows whenever a method is updated, rather than try to be smart about it. That simplifies this PR a lot, but unfortunately, and I normally hate to do this after a review has started, it did mean I had to rebase and force push to drop the relevant commits.

Copy link
Member

@tmat tmat left a comment

Choose a reason for hiding this comment

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

:shipit:

@davidwengier
Copy link
Contributor Author

@cston Care to have another look?
@RikkiGibson Can you review?

Would love to get this in before snap tomorrow.

@RikkiGibson RikkiGibson self-assigned this Jul 27, 2021

if (methodChange == SymbolChange.Added)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm assuming the behavior of type parameters is unchanged here, i.e. adding an attribute to a type parameter during an EnC session is not supported.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, editing generic types is not supported.


private void EmitParametersFromDelta(IMethodDefinition methodDef, MethodDefinitionHandle handle)
{
var ok = _previousGeneration.FirstParamRowMap.TryGetValue(handle, out var firstRowId);
Copy link
Contributor

Choose a reason for hiding this comment

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

It feels like it might be reasonable to fail in retail builds here if the handle isn't present, e.g. by changing the code to var firstRowId = _previousGeneration.FirstParamRowMap[handle]. However, I don't know exactly what the failure mode is here if we proceed into the loop with a firstRowId which is just 0 instead of being something meaningful for the given handle.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This would still fail later, when trying to emit an EncLog row for Param row 0, and I think that would give a more descriptive exception that "element not found".

Realistically this can only fail if someone changes how EnC works in a way that would break a lot of things, like perhaps allowing direct creation of a delta without a baseline, so a debug assert feels appropriate to me.

@davidwengier davidwengier merged commit 3d8acbd into dotnet:main Jul 27, 2021
@ghost ghost added this to the Next milestone Jul 27, 2021
@davidwengier davidwengier deleted the EnCEmitParametersOnMethodUpdate branch July 27, 2021 19:46
@davidwengier
Copy link
Contributor Author

Thanks all!

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.

EnC - Attribute updates on parameters don't get emitted
5 participants