예제 #1
0
 /// <summary>
 /// Generates the syntax for a property member.
 /// </summary>
 public static MemberDeclarationSyntax GeneratePropertySyntax(LocalisationMember member)
 => SyntaxFactory.ParseMemberDeclaration(
     string.Format(SyntaxTemplates.PROPERTY_MEMBER_TEMPLATE,
                   member.Name,
                   member.Key,
                   convertToVerbatim(member.EnglishText),
                   member.EnglishText)) !;
예제 #2
0
 /// <summary>
 /// Generates the syntax for accessing the member.
 /// </summary>
 public static MemberAccessExpressionSyntax GenerateMemberAccessSyntax(LocalisationFile localisationFile, LocalisationMember member)
 => SyntaxFactory.MemberAccessExpression(
     SyntaxKind.SimpleMemberAccessExpression,
     SyntaxFactory.IdentifierName(localisationFile.Name),
     SyntaxFactory.IdentifierName(member.Name));
예제 #3
0
        /// <summary>
        /// Generates the syntax for a method member.
        /// </summary>
        public static MemberDeclarationSyntax GenerateMethodSyntax(Workspace workspace, LocalisationMember member)
        {
            var paramList = SyntaxFactory.ParameterList(
                SyntaxFactory.SeparatedList(
                    member.Parameters.Select(param => SyntaxFactory.Parameter(
                                                 SyntaxFactory.Identifier(param.Name))
                                             .WithType(
                                                 SyntaxFactory.IdentifierName(param.Type)))));

            var argList = SyntaxFactory.ArgumentList(
                SyntaxFactory.SeparatedList(
                    member.Parameters.Select(param => SyntaxFactory.Argument(
                                                 SyntaxFactory.IdentifierName(param.Name)))));

            return(SyntaxFactory.ParseMemberDeclaration(
                       string.Format(SyntaxTemplates.METHOD_MEMBER_TEMPLATE,
                                     member.Name,
                                     Formatter.Format(paramList, workspace).ToFullString(),
                                     member.Key,
                                     convertToVerbatim(member.EnglishText),
                                     Formatter.Format(argList, workspace).ToFullString()[1..^ 1], // The entire string minus the parens
                                     member.EnglishText)) !);                                     // Todo: Improve xmldoc
        }