Tweak how we generate the IDisposable.Dispose pattern.#42426
Tweak how we generate the IDisposable.Dispose pattern.#42426CyrusNajmabadi merged 23 commits intodotnet:masterfrom
Conversation
…tInterfaceService.CodeAction.cs
|
Ok. Have moved to a model where this is almost all done with standard code gen. |
| Module Program | ||
| Sub Main() | ||
| If True Then | ||
|
|
There was a problem hiding this comment.
changed because i tweaked the formatter to not introduce a blank line with nested if-statements + elastic trivia.
| </data> | ||
| <data name="TODO_colon_uncomment_the_following_line_if_the_finalizer_is_overridden_above" xml:space="preserve"> | ||
| <value>TODO: uncomment the following line if the finalizer is overridden above.</value> | ||
| </data> |
There was a problem hiding this comment.
all resources moved to features layer.
| return ifStatement.ReplaceToken( | ||
| ifStatement.GetLastToken(), | ||
| ifStatement.GetLastToken().WithPrependedLeadingTrivia(trivia)); | ||
| } |
There was a problem hiding this comment.
i couldn't find a language agnostic way to do this. So VB and C# both have way to add a comment inside their if-block.
| return options.AutoInsertionLocation | ||
| ? AddMembersToAppropiateLocationInDestination(destination, filteredMembers, availableIndices, options, cancellationToken) | ||
| : AddMembersToEndOfDestination(destination, filteredMembers, availableIndices, options, cancellationToken); | ||
| : AddMembersToEndOfDestination(destination, filteredMembers, options, cancellationToken); |
There was a problem hiding this comment.
unused param.
| INamespaceOrTypeSymbol destination, | ||
| Func<SyntaxNode, CodeGenerationOptions, IList<bool>, CancellationToken, SyntaxNode> declarationTransform, | ||
| CodeGenerationOptions options, | ||
| IEnumerable<ISymbol> members, |
There was a problem hiding this comment.
unused param.
| TypeOf previousStatement Is TypeStatementSyntax Then | ||
| TypeOf previousStatement Is TypeStatementSyntax OrElse | ||
| TypeOf previousStatement Is IfStatementSyntax Then | ||
| Return GetActualLines(previousToken, currentToken, 1) |
There was a problem hiding this comment.
tweaked elastic formatting of nested ifs to not put in a blank line.
| }} | ||
| #endregion"; | ||
| // {string.Format(FeaturesResources.Do_not_change_this_code_Put_cleanup_code_in_0_method, "Dispose(bool disposing)")} | ||
| Dispose(disposing: true); |
There was a problem hiding this comment.
💭 I'm not a huge fan of making this a named argument, but I'm ignoring it for now since the long-term goal is to remove the Dispose(bool) method altogether.
|
Thanks! |
Fixes #9760
A few improvements:
#regions. We stopped generating regions for interfaces years ago. This brings IDisposable in line with that.