Skip to content

Conversation

AlekseyTs
Copy link
Contributor

@AlekseyTs AlekseyTs commented Sep 18, 2025

Closes #79894.

Relates to test plan #76130

return groupingTypes;
}

public sealed override ImmutableArray<Cci.ExportedType> GetExportedTypes(EmitContext context)
Copy link
Member

@jjonescz jjonescz Sep 19, 2025

Choose a reason for hiding this comment

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

Consider passing EmitContext as in since it's a large structure. #Resolved

Copy link
Contributor Author

@AlekseyTs AlekseyTs Sep 19, 2025

Choose a reason for hiding this comment

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

Consider passing EmitContext as in since it's a large structure.

I'll stick to the current way of passing. As far as I can see in existing code, it is passed everywhere by value. If that becomes a real problem we would need to change all of them. Also, VB doesn't have a concept of in, but this method is also overridden in VB.


while (stack.Count > currentStackSize)
{
processTopItemFromStack(stack, context, builder);
Copy link
Member

@jjonescz jjonescz Sep 19, 2025

Choose a reason for hiding this comment

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

Why are we processing the newly pushed types here immediately instead of processing them in the top-level loop? #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.

Why are we processing the newly pushed types here immediately instead of processing them in the top-level loop?

Because we want to process them before we append grouping and marker types. And we want to append grouping and marker types before processing anything else from the stack. That ensures consistent ordering across all different forms of extensions representation.

using System.Reflection.Metadata;
using System.Runtime.CompilerServices;
using System.Threading;
using Microsoft.Cci;
Copy link
Member

@jjonescz jjonescz Sep 19, 2025

Choose a reason for hiding this comment

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

This using looks unnecessary if we use Cci. prefix in the code 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.

This using looks unnecessary

IDE generated stubs for interface implementation and added this using in the process. That code doesn't use prefix.

internal override string? ExtensionMarkerName
=> _underlyingType.ExtensionMarkerName;

#nullable enable
Copy link
Member

@jjonescz jjonescz Sep 19, 2025

Choose a reason for hiding this comment

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

This seems superfluous - there is already #nullable enable a few lines above. #Pending


internal ImmutableArray<(Cci.INestedTypeReference GroupingType, ImmutableArray<Cci.INestedTypeReference> MarkerTypes)> GetExtensionGroupingAndMarkerTypesForTypeForwarding(EmitContext context)
{
if (_lazyExtensionGroupingAndMarkerTypesForTypeForwarding.IsDefault)
Copy link
Member

@jjonescz jjonescz Sep 19, 2025

Choose a reason for hiding this comment

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

Is it guaranteed that this won't be called twice with a different EmitContext (which could mean getting a stale cached value)? #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.

Is it guaranteed that this won't be called twice with a different EmitContext

No, but the actual implementation of the called APIs doesn't use the context.

Copy link
Member

Choose a reason for hiding this comment

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

That sounds fragile to me. Consider mentioning that in a comment on the implementation side.


foreach (var groupingType in groupingTypes)
{
var retargetedGroupingType = new ForwardedExtensionGroupingOrMarkerType(this.GetCciAdapter(), groupingType);
Copy link
Member

@jjonescz jjonescz Sep 19, 2025

Choose a reason for hiding this comment

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

Suggested change
var retargetedGroupingType = new ForwardedExtensionGroupingOrMarkerType(this.GetCciAdapter(), groupingType);
var forwardedGroupingType = new ForwardedExtensionGroupingOrMarkerType(this.GetCciAdapter(), groupingType);
``` #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.

The current name looks fine to me

@AlekseyTs AlekseyTs requested review from jjonescz and a team September 19, 2025 15:47
@jcouv jcouv self-assigned this Sep 21, 2025

internal ImmutableArray<(Cci.INestedTypeReference GroupingType, ImmutableArray<Cci.INestedTypeReference> MarkerTypes)> GetExtensionGroupingAndMarkerTypesForTypeForwarding(EmitContext context)
{
if (_lazyExtensionGroupingAndMarkerTypesForTypeForwarding.IsDefault)
Copy link
Member

Choose a reason for hiding this comment

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

That sounds fragile to me. Consider mentioning that in a comment on the implementation side.

@AlekseyTs AlekseyTs merged commit b8daa4c into dotnet:main Sep 22, 2025
24 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Sep 22, 2025
@akhera99 akhera99 modified the milestones: Next, 18.0 P1, 18.0 P2 Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Feature - Extension Everything The extension everything feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Roslyn hits "unreachable" exception when processing type forward to a class containing an extension group
5 participants