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

Address remaining prototype comments #53929

Conversation

chsienki
Copy link
Contributor

@chsienki chsienki commented Jun 7, 2021

Fixes various issue remaining with the feature, may be easiest to go commit by commit.

Note there is still one remaining comment here: https://github.com/chsienki/roslyn/blob/2a2d444eaa27a53cf84011645cbc729b5a9adc5d/src/Compilers/CSharp/Test/Semantic/SourceGeneration/GeneratorDriverTests.cs#L459 which is a skipped test. We should decide if the behavior difference is acceptable or not.

@chsienki chsienki requested a review from a team as a code owner June 7, 2021 22:53
Copy link
Member

@jaredpar jaredpar left a comment

Choose a reason for hiding this comment

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

Couple minor fixes

state = _comparer.Equals(builder.GetLastEntries()[0], entry) ? EntryState.Cached : EntryState.Modified;
}

builder.AddEntry(entry, state);
Copy link
Member

Choose a reason for hiding this comment

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

Need to add tests for this change / commit (making Join comparable)


var exception = Assert.Throws<ArgumentException>(() => asc.Add("file5.cs", SourceText.From("", encoding: null)));

// check the exception contains the excpected
Copy link
Member

@cston cston Jun 8, 2021

Choose a reason for hiding this comment

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

excpected

Typo. #Closed

var source = @"
class C { }
";
var parseOptions = TestOptions.Regular.WithLanguageVersion(LanguageVersion.Preview);
Copy link
Member

Choose a reason for hiding this comment

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

TestOptions.RegularPreview

Assert.Equal(texts[0], calledFor[0].Item2.Single());

// edit the additional texts, and verify that the output was *not* called again on the next run
driver = driver.RemoveAdditionalTexts(texts.ToImmutableArray());
Copy link
Member

Choose a reason for hiding this comment

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

ToImmutableArray()

It looks like CSharpGeneratorDriver.Create() takes an IEnumerable<AdditionalText> while AddAdditionalTexts() and RemoveAdditionalTexts() take an ImmutableArray<AdditionalText>. Is there a reason for the difference?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Create is just a helper method, and calls ToImmutableArray() under the hood. We should probably expose a Create overload that takes an ImmutableArray directly, but this is the same as V1.

@chsienki chsienki merged commit f6a211e into dotnet:features/source-generators Jun 8, 2021
@chsienki chsienki deleted the source-generators/proto-comments branch June 9, 2021 17:05
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.

3 participants