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

Add generation for all IOperation nodes #38056

Merged
merged 5 commits into from
Aug 20, 2019

Conversation

333fred
Copy link
Member

@333fred 333fred commented Aug 16, 2019

Almost all IOperation implementations in Microsoft.CodeAnalysis are now being generated. Exceptions are main NoneOperation, InvalidOperation, and the operations that involve dynamic, as we have a special base class they all inherit from internally that's used to implement some public API functionality. Unfortunately, as in the previous PR, I was unable to generate these new classes in-place. I've done some reordering of properties in the xml to make the constructors generate parameters in the same order as they did previously, but in a few cases that wasn't possible, and for those cases I've reordered parameters in other files. I've also standardized the names of the IConvertibleConversion properties, which caused a few renames in the code as well.

I've also added a verification step for the XML, to help prevent simple errors from being introduced. It will ensure that children have an explicit ordering if required, that operations follow naming conventions, that base types are correctly specified, and that summaries are appropriately included. @dotnet/roslyn-compiler please review.

@333fred 333fred requested a review from a team August 16, 2019 20:37
@333fred
Copy link
Member Author

333fred commented Aug 19, 2019

@dotnet/roslyn-compiler please review. #Closed

@@ -3504,14 +3504,14 @@ private void AddExceptionStore(ITypeSymbol exceptionType, IOperation exceptionDe
if (exceptionTarget != null)
{
AddStatement(new SimpleAssignmentOperation(
exceptionTarget,
isRef: false,
Copy link
Contributor

@RikkiGibson RikkiGibson Aug 19, 2019

Choose a reason for hiding this comment

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

formatting? #Resolved

default:
return new SimpleAssignmentOperation(Visit(operation.LoopControlVariable),
isRef: false, // In C# this is an error case and VB doesn't support ref locals
Copy link
Contributor

@RikkiGibson RikkiGibson Aug 19, 2019

Choose a reason for hiding this comment

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

seems like this comment was meant to remain attached toisRef: false? #Resolved

@@ -77,7 +77,7 @@
</Comments>
</Property>
</Node>
<Node Name="ISwitchOperation" Base="IOperation">
<Node Name="ISwitchOperation" Base="IOperation" ChildrenOrder="Value,Cases">
Copy link
Contributor

@RikkiGibson RikkiGibson Aug 19, 2019

Choose a reason for hiding this comment

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

ChildrenOrder [](start = 50, length = 13)

It seems like sometimes it's validated that all properties are present in ChildrenOrder, but properties like Locals are not included. What am I missing about the way the validation works? #Closed

Copy link
Member Author

Choose a reason for hiding this comment

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

Children are only IOperation or arrays of IOperation.


In reply to: 315387892 [](ancestors = 315387892)

@cston
Copy link
Member

cston commented Aug 19, 2019

                ImmutableInterlocked.InterlockedCompareExchange(ref _lazyOperations, operations, default);

ImmutableInterlocked.InterlockedInitialize() here and other instances. #Resolved


Refers to: src/Compilers/Core/Portable/Generated/Operations.Generated.cs:2808 in ddee7cd. [](commit_id = ddee7cd, deletion_comment = False)

@cston
Copy link
Member

cston commented Aug 19, 2019

using System;

Copyright header.

Or simply merge this with the other partial. #Resolved


Refers to: src/Tools/Source/CompilerGeneratorTools/Source/IOperationGenerator/IOperationClassWriter.Verifier.cs:1 in ddee7cd. [](commit_id = ddee7cd, deletion_comment = False)

@@ -340,80 +348,202 @@ private void WriteClasses()
if (type.SkipClassGeneration) continue;

var allProps = GetAllProperties(type);
bool hasSkippedProperties = !GetAllProperties(type, includeSkipGenerationProperties: true).SequenceEqual(allProps);
var ioperationTypes = allProps.Where(p => IsIOperationType(p.Type)).ToList();
Copy link
Member

@cston cston Aug 19, 2019

Choose a reason for hiding this comment

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

ioperationTypes [](start = 20, length = 15)

Consider naming ioperationProps. #Resolved

@333fred
Copy link
Member Author

333fred commented Aug 19, 2019

using System;

I wanted to break this up to avoid putting too much in one file, I'll add a copyright header.


In reply to: 522740001 [](ancestors = 522740001)


Refers to: src/Tools/Source/CompilerGeneratorTools/Source/IOperationGenerator/IOperationClassWriter.Verifier.cs:1 in ddee7cd. [](commit_id = ddee7cd, deletion_comment = False)

Copy link
Contributor

@RikkiGibson RikkiGibson left a comment

Choose a reason for hiding this comment

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

:shipit:

{
if (prop.Comments?.Elements?[0].Name != "summary" && !prop.IsInternal)
{
Console.WriteLine($"{abstractNode.Name}.{prop.Name} does not have correctly formatted comments, please ensure that there is a <summary> block for the type.");
Copy link
Member

@cston cston Aug 19, 2019

Choose a reason for hiding this comment

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

type [](start = 178, length = 4)

"property"? #Resolved


if (!abstractNode.Name.EndsWith("Operation"))
{
Console.WriteLine($"All IOperation node names must end with Operation. {abstractNode.Name} does not.");
Copy link
Member Author

@333fred 333fred Aug 19, 2019

Choose a reason for hiding this comment

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

Add error = true; #Resolved


if (node.ChildrenOrder is null)
{
Console.WriteLine($"{node.Name} has more than 1 IOperation properties and must declare an explicit ordering with the ChildrenOrder attribute.");
Copy link
Member

@cston cston Aug 19, 2019

Choose a reason for hiding this comment

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

properties [](start = 79, length = 10)

"property"? #Resolved

continue;
}

var childrenOrdered = node.ChildrenOrder.Split(",", StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()).ToList();
Copy link
Member

@cston cston Aug 19, 2019

Choose a reason for hiding this comment

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

.Split(",", StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()) [](start = 56, length = 72)

Perhaps extract a helper method. #Resolved

…ange with default, minor formatting and naming suggestions.
@333fred
Copy link
Member Author

333fred commented Aug 19, 2019

@RikkiGibson @cston addressed feedback. #Closed

if (ioperationTypes.Count == 0)
bool hasSkippedProperties = !GetAllProperties(type, includeSkipGenerationProperties: true).SequenceEqual(allProps);
var ioperationProperties = allProps.Where(p => IsIOperationType(p.Type)).ToList();
var publicIOperationTypes = ioperationProperties.Where(p => !p.IsInternal).ToList();
Copy link
Member

@cston cston Aug 19, 2019

Choose a reason for hiding this comment

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

publicIOperationTypes [](start = 20, length = 21)

publicIOperationProperties? #Resolved

{
if (node.ChildrenOrder is string order)
{
var splitOrder = order.Split(",", StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()).ToList();
Copy link
Member

@cston cston Aug 19, 2019

Choose a reason for hiding this comment

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

order.Split(",", StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()).ToList(); [](start = 41, length = 87)

GetPropertyOrder(order) #Resolved

@jcouv jcouv added this to the 16.4.P1 milestone Aug 20, 2019
@333fred 333fred merged commit 20f6117 into dotnet:release/dev16.4-preview1 Aug 20, 2019
@333fred 333fred deleted the generate-operations branch August 20, 2019 17:53
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