Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private static SyntaxNode GetReplacementNode(SemanticModel semanticModel, Syntax

private static SyntaxNode TransformGenericNameToTuple(SemanticModel semanticModel, GenericNameSyntax genericName)
{
var implementationType = typeof(SeparatedSyntaxListWrapper<>.AutoWrapSeparatedSyntaxList<>).MakeGenericType(typeof(TupleElementSyntaxWrapper), WrapperHelper.GetWrappedType(typeof(TupleElementSyntaxWrapper)));
var implementationType = typeof(SeparatedSyntaxListWrapper<>.AutoWrapSeparatedSyntaxList<>).MakeGenericType(typeof(TupleElementSyntaxWrapper), SyntaxWrapperHelper.GetWrappedType(typeof(TupleElementSyntaxWrapper)));
var tupleElements = (SeparatedSyntaxListWrapper<TupleElementSyntaxWrapper>)Activator.CreateInstance(implementationType);

foreach (var typeArgument in genericName.TypeArgumentList.Arguments)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ private void GenerateOperationInterface(in GeneratorExecutionContext context, In
identifier: SyntaxFactory.Identifier(node.WrapperName),
parameterList: SyntaxFactory.ParameterList(),
initializer: null,
body: SyntaxFactory.Block(staticCtorStatements)));
body: SyntaxFactory.Block(staticCtorStatements),
expressionBody: null));

// private IArgumentOperationWrapper(IOperation operation)
// {
Expand All @@ -203,7 +204,8 @@ private void GenerateOperationInterface(in GeneratorExecutionContext context, In
SyntaxKind.SimpleMemberAccessExpression,
expression: SyntaxFactory.ThisExpression(),
name: SyntaxFactory.IdentifierName("operation")),
right: SyntaxFactory.IdentifierName("operation"))))));
right: SyntaxFactory.IdentifierName("operation")))),
expressionBody: null));

// public IOperation WrappedOperation => this.operation;
members = members.Add(SyntaxFactory.PropertyDeclaration(
Expand Down Expand Up @@ -679,7 +681,8 @@ private void GenerateOperationWrapperHelper(in GeneratorExecutionContext context
identifier: SyntaxFactory.Identifier("OperationWrapperHelper"),
parameterList: SyntaxFactory.ParameterList(),
initializer: null,
body: SyntaxFactory.Block(staticCtorStatements));
body: SyntaxFactory.Block(staticCtorStatements),
expressionBody: null);

// internal static Type GetWrappedType(Type wrapperType)
// {
Expand Down Expand Up @@ -831,7 +834,7 @@ public DocumentData(XDocument document)

if (!operationKinds.TryGetValue(node.Attribute("Name").Value, out var kinds))
{
kinds = ImmutableArray<(string name, int value, string extraDescription)>.Empty;
kinds = ImmutableArray<(string name, int value, string? extraDescription)>.Empty;
}

var interfaceData = new InterfaceData(this, node, kinds);
Expand All @@ -847,7 +850,7 @@ public DocumentData(XDocument document)

if (!operationKinds.TryGetValue(node.Attribute("Name").Value, out var kinds))
{
kinds = ImmutableArray<(string name, int value, string extraDescription)>.Empty;
kinds = ImmutableArray<(string name, int value, string? extraDescription)>.Empty;
}

var interfaceData = new InterfaceData(this, node, kinds);
Expand All @@ -859,11 +862,11 @@ public DocumentData(XDocument document)

public ReadOnlyDictionary<string, InterfaceData> Interfaces { get; }

private static ImmutableDictionary<string, ImmutableArray<(string name, int value, string extraDescription)>> GetOperationKinds(XDocument document)
private static ImmutableDictionary<string, ImmutableArray<(string name, int value, string? extraDescription)>> GetOperationKinds(XDocument document)
{
var skippedOperationKinds = GetSkippedOperationKinds(document);

var builder = ImmutableDictionary.CreateBuilder<string, ImmutableArray<(string name, int value, string extraDescription)>>();
var builder = ImmutableDictionary.CreateBuilder<string, ImmutableArray<(string name, int value, string? extraDescription)>>();

int operationKind = 0;
foreach (var node in document.XPathSelectElements("/Tree/AbstractNode|/Tree/Node"))
Expand All @@ -886,7 +889,7 @@ public DocumentData(XDocument document)
}
else if (explicitKind.XPathSelectElements("Entry").Any())
{
var nodeBuilder = ImmutableArray.CreateBuilder<(string name, int value, string extraDescription)>();
var nodeBuilder = ImmutableArray.CreateBuilder<(string name, int value, string? extraDescription)>();
foreach (var entry in explicitKind.XPathSelectElements("Entry"))
{
if (entry.Attribute("EditorBrowsable")?.Value == "false")
Expand Down Expand Up @@ -918,7 +921,7 @@ public DocumentData(XDocument document)

var nodeName = node.Attribute("Name").Value;
var kindName = nodeName.Substring("I".Length, nodeName.Length - "I".Length - "Operation".Length);
builder.Add(nodeName, ImmutableArray.Create((kindName, operationKind, (string)null)));
builder.Add(nodeName, ImmutableArray.Create((kindName, operationKind, (string?)null)));
}

return builder.ToImmutable();
Expand Down Expand Up @@ -955,7 +958,7 @@ private sealed class InterfaceData
{
private readonly DocumentData documentData;

public InterfaceData(DocumentData documentData, XElement node, ImmutableArray<(string name, int value, string extraDescription)> operationKinds)
public InterfaceData(DocumentData documentData, XElement node, ImmutableArray<(string name, int value, string? extraDescription)> operationKinds)
{
this.documentData = documentData;

Expand All @@ -968,7 +971,7 @@ public InterfaceData(DocumentData documentData, XElement node, ImmutableArray<(s
this.Properties = node.XPathSelectElements("Property").Select(property => new PropertyData(property)).ToImmutableArray();
}

public ImmutableArray<(string name, int value, string extraDescription)> OperationKinds { get; }
public ImmutableArray<(string name, int value, string? extraDescription)> OperationKinds { get; }

public string InterfaceName { get; }

Expand All @@ -982,7 +985,7 @@ public InterfaceData(DocumentData documentData, XElement node, ImmutableArray<(s

public ImmutableArray<PropertyData> Properties { get; }

public InterfaceData BaseInterface
public InterfaceData? BaseInterface
{
get
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -16,6 +17,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.8.0-5.final" />
<PackageReference Include="TunnelVisionLabs.ReferenceAssemblyAnnotator" Version="1.0.0-alpha.160" PrivateAssets="all" />
<PackageDownload Include="Microsoft.NETCore.App.Ref" Version="[3.1.0]" />
</ItemGroup>

</Project>
Loading