public override SyntaxNode VisitMethodDeclaration(MethodDeclarationSyntax node) { var newMethod = VisitMemberDeclaration(node, base.VisitMethodDeclaration(node)); if (node.HasAttribute<ExpectedOutputAttribute>()) { ExerciseClassName = ExerciseClassName ?? FindParentClassName(node); Exercise.ExpectedOutput = node.GetAttributes<ExpectedOutputAttribute>().Select(attr => attr.GetArgument(0)).FirstOrDefault(); } if (node.HasAttribute<HideExpectedOutputOnErrorAttribute>()) Exercise.HideExpectedOutputOnError = true; if (node.HasAttribute<HintAttribute>()) Exercise.HintsMd.AddRange(node.GetAttributes<HintAttribute>().Select(attr => attr.GetArgument(0))); if (node.HasAttribute<CommentAfterExerciseIsSolved>()) Exercise.CommentAfterExerciseIsSolved = node.GetAttributes<CommentAfterExerciseIsSolved>().Single().GetArgument(0); if (node.HasAttribute<ExerciseAttribute>()) { ExerciseClassName = ExerciseClassName ?? FindParentClassName(node); Exercise.EthalonSolution += node.WithoutAttributes(); Exercise.ExerciseInitialCode = GetExerciseCode(node); if (node.HasAttribute<SingleStatementMethodAttribute>()) Exercise.ValidatorName += " SingleStatementMethod"; } return newMethod; }
private string CreateCodeBlock(MethodDeclarationSyntax node) { return node.HasAttribute<ShowBodyOnSlideAttribute>() ? node.Body.Statements.ToFullString().RemoveCommonNesting() : node.WithoutAttributes().ToPrettyString(); }