Skip to content

Commit

Permalink
Merge pull request #3774 from sharwell/type-extensions
Browse files Browse the repository at this point in the history
Define lightup method for TypeDeclarationSyntax.ParameterList
  • Loading branch information
sharwell authored Jan 10, 2024
2 parents 48b4083 + c4b59b3 commit b88cf52
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

namespace StyleCop.Analyzers.Lightup;

using System;
using Microsoft.CodeAnalysis.CSharp.Syntax;

internal static class TypeDeclarationSyntaxExtensions
{
private static readonly Func<TypeDeclarationSyntax, ParameterListSyntax?> ParameterListAccessor;
private static readonly Func<TypeDeclarationSyntax, ParameterListSyntax?, TypeDeclarationSyntax> WithParameterListAccessor;

static TypeDeclarationSyntaxExtensions()
{
ParameterListAccessor = LightupHelpers.CreateSyntaxPropertyAccessor<TypeDeclarationSyntax, ParameterListSyntax>(typeof(TypeDeclarationSyntax), nameof(ParameterList));
WithParameterListAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor<TypeDeclarationSyntax, ParameterListSyntax?>(typeof(TypeDeclarationSyntax), nameof(ParameterList));
}

public static ParameterListSyntax? ParameterList(this TypeDeclarationSyntax syntax)
{
return ParameterListAccessor(syntax);
}

public static TypeDeclarationSyntax WithParameterList(this TypeDeclarationSyntax syntax, ParameterListSyntax? parameterList)
{
return WithParameterListAccessor(syntax, parameterList);
}
}

0 comments on commit b88cf52

Please sign in to comment.