Repository navigation
Keep the source generator running on [Blocks(null)] and case clashes - #3124
Merged
Merged
Conversation
… that differ in case
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The two inputs from the review of M4 and M6 that stopped the source generator (
CS8785) and left a compilation with no builders, plus three follow-ups from the review of this pull request. Each item got a failing test first.Closes #3071
What changed
[Blocks(null)].SymbolReaderskips an array argument thatIsNull, so the field gets no member and no word, its class keeps a builder with its other fields, and the other classes keep theirs.[Blocks]is the only array argument the generator enumerates. The host now refuses[Blocks(null)]withFCMS1211, the code it gives[Blocks]with no types, where it failed with aNullReferenceException. The analyzers report it withFCMS0011, where they reported nothing.FieldsEmittercompares class names ignoring case, as Roslyn compares hint names and asgeneratecompares its files.x-yandxygiveXYFieldsandXyFields: the first in the emitter's order gets the builder, the second gets none andFCMS0100. Because the tool shares the emitter,generate csharpnow writes such a schema, warningFCMS0100for the second builder, where it refused it withFCMS3380.FCMS0104), as the tool'sTypeNamesgives that type its class. For blocksa-bandab,abnow gets neither a builder (FCMS0100) nor a class (FCMS3376), where it got the builderAbBlockFieldswhilea-bkept the classABBlock. TheFCMS0100message is now "because another type takes the name X, in this case or another".[Select(null)]. The host now refuses it withFCMS1216, where it failed with aNullReferenceException. On an enum it gets the message for a list on an enum, and elsewhere the message for no options. The analyzers report it with the matching rule,FCMS0007orFCMS0008, where they skipped it. The generator still gives the field its member, as it does for[Select]with no options.Spec 6.1 and 6.4,
docs/analyzers.md(FCMS0007,FCMS0008,FCMS0011) and the tool's README say what was built. No new codes.Decisions
[Blocks(null)]field is left out on its own and its class keeps its builder. The generator already does this for[Blocks()]and for a blocks field whose types are not blocks.SchemaModelgives the tool'sTypeNames, so the tool and the generator keep the same type.TypeNamesskipping the block: a block type with a hyphen still needs its class in a client to read its JSON. In a host,abbesidea-bloses the builder it had, andFCMS0100says why.[Select(null)]is refused on an enum too, rather than read as[Select]with the enum's members as its options, sonullgets no new meaning.Tests
[Blocks(null)]beside another collection gives every builder, none withBody, and no exception or diagnostic.x-yandxybeside another collection giveXYFieldsand the other builders, oneFCMS0100at the class ofxy, and no exception.a-bandabgive no builder, withFCMS0104andFCMS0100.[Blocks(null!)]isFCMS1211, and[Select(null!)]isFCMS1216on a string and on an enum. Analyzers: they areFCMS0011,FCMS0008andFCMS0007, andLeftToTheHostTestsno longer treats either as unreported.generate csharponfoo-barandfoobarexits 0, writesFooBar.g.csandFooBarFields.g.cs, and warnsFCMS0100. Blocksa-bandabgiveABBlock.g.csand no class or builder forab, in C# and in TypeScript.dotnet build -c Release -warnaserroris clean. The Generators (138), Sdk (148), Core (1572) and Architecture (24) tests and the tool'sGenerateTestsclass (22) pass in Release. Markdown lint is clean.