Skip to content

Conversation

@jaredpar
Copy link
Member

  • Fix generator error on command line

The latest compiler was throwing when generators took advantage of the new API ForAttributeWithMetadataName with an exception trying to compare CompilationOption values. The reason is that we didn't plumb ReferenceEqualityComparer in both the places it was needed. Doing that fixed the bug.

The reason this was never caught during testing is that we create CompilationOptions differently in testing vs. the command line. The command line inserts a LoggingMetadataFileReferenceResolver instance which throws on all equality methods. The reasons for this are unknown but it is the behavior we have. The CompilationOptions used in testing do normal value based equality checks. This created a significant test gap for us.

This change introduces a new CompilationOptions helper that throws on equality checks. Once that was introduced into the generator tests we saw everything fail as expected. After fixing the bug the tests all moved back to passing.

closes #63318

  • PR feedback

* Fix generator error on command line

The latest compiler was throwing when generators took advantage of the
new API `ForAttributeWithMetadataName` with an exception trying to
compare `CompilationOption` values. The reason is that we didn't plumb
`ReferenceEqualityComparer` in both the places it was needed. Doing that
fixed the bug.

The reason this was never caught during testing is that we create
`CompilationOptions` differently in testing vs. the command line. The
command line inserts a `LoggingMetadataFileReferenceResolver` instance
which throws on all equality methods. The reasons for this are unknown
but it is the behavior we have. The `CompilationOptions` used in testing
do normal value based equality checks. This created a significant test
gap for us.

This change introduces a new `CompilationOptions` helper that throws on
equality checks. Once that was introduced into the generator tests we
saw everything fail as expected. After fixing the bug the tests all
moved back to passing.

closes dotnet#63318

* PR feedback
@jaredpar jaredpar requested a review from a team as a code owner September 14, 2022 17:47
@ghost ghost added the Area-Compilers label Sep 14, 2022
public static readonly InputNode<Compilation> Compilation = new InputNode<Compilation>(b => ImmutableArray.Create(b.Compilation));

public static readonly InputNode<CompilationOptions> CompilationOptions = new(b => ImmutableArray.Create(b.Compilation.Options));
public static readonly InputNode<CompilationOptions> CompilationOptions = new(b => ImmutableArray.Create(b.Compilation.Options), ReferenceEqualityComparer.Instance);
Copy link
Member

Choose a reason for hiding this comment

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

doc?

@jaredpar jaredpar enabled auto-merge (squash) September 14, 2022 18:58
@jaredpar
Copy link
Member Author

Merging as only remaining test is spanish and that won't impact this particular fix. Need some expediancy with this fix.

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.

4 participants