From 3fcce9039a07ca2ed632f3732f27ce726b787054 Mon Sep 17 00:00:00 2001 From: Marcin Celej Date: Thu, 21 Dec 2023 13:38:11 +0100 Subject: [PATCH] #27: Changed order of types and methods in generated api description --- ....Synergy.Architecture.Diagrams.verified.md | 90 ++-- .../Api.of.Synergy.Contracts.verified.md | 136 ++--- .../Api.of.Synergy.Documentation.verified.md | 172 +++--- .../Api/ApiDescription.cs | 75 +-- ...Api.of.Synergy.Web.Api.Testing.verified.md | 510 +++++++++--------- 5 files changed, 504 insertions(+), 479 deletions(-) diff --git a/Architecture/Synergy.Architecture.Tests/Architecture/Public/Api.of.Synergy.Architecture.Diagrams.verified.md b/Architecture/Synergy.Architecture.Tests/Architecture/Public/Api.of.Synergy.Architecture.Diagrams.verified.md index bf2cb5a..91d7846 100644 --- a/Architecture/Synergy.Architecture.Tests/Architecture/Public/Api.of.Synergy.Architecture.Diagrams.verified.md +++ b/Architecture/Synergy.Architecture.Tests/Architecture/Public/Api.of.Synergy.Architecture.Diagrams.verified.md @@ -1,5 +1,42 @@ # Synergy.Architecture.Diagrams +## Documentation.TechnicalBlueprint (class) + - ctor() + - Add( + diagrams: IEnumerable + ) : TechnicalBlueprint + - Add( + diagrams: params SequenceDiagram[] [ParamArray] + ) : TechnicalBlueprint + - Intro( + markdown: string + ) : TechnicalBlueprint + - Register( + interface: Type, + implementation: Type + ) : TechnicalBlueprint + - Register( + interface: Type, + services: IServiceProvider + ) : TechnicalBlueprint + - Register() : TechnicalBlueprint + - Render() : string + - TechnicalBlueprint.Titled( + title: string + ) : TechnicalBlueprint + - ToString() : string + +## Documentation.TechnicalBlueprint+DiagramComponents (class) + - ctor() + - Register( + interface: Type, + implementation: Type + ) : void + - Register() : void [NullableContext] + - Resolve( + origin: Type + ) : Type + ## Sequence.SequenceDiagram (record) : IEquatable - Actor: SequenceDiagramActor [Nullable] { get; set; } - Components: TechnicalBlueprint+DiagramComponents? { get; set; } @@ -15,32 +52,32 @@ Components: TechnicalBlueprint+DiagramComponents? [Optional], TitleText: string? [Optional] ) - - Calling( + - Calling( + method: MethodInfo + ) : SequenceDiagram [NullableContext] + - Calling( + type: Type, methodName: string, arguments: params Type[] [ParamArray] ) : SequenceDiagram [NullableContext] - Calling( call: Expression> ) : SequenceDiagram [NullableContext] - - Calling( - type: Type, + - Calling( methodName: string, arguments: params Type[] [ParamArray] ) : SequenceDiagram [NullableContext] - - Calling( - method: MethodInfo - ) : SequenceDiagram [NullableContext] - CutOff( types: params Type[] [ParamArray] ) : SequenceDiagram [NullableContext] - Footer( footer: string ) : SequenceDiagram [NullableContext] - - SequenceDiagram.From() : SequenceDiagram [NullableContext] + - Render() : string [NullableContext] - SequenceDiagram.From( actor: SequenceDiagramActor ) : SequenceDiagram [NullableContext] - - Render() : string [NullableContext] + - SequenceDiagram.From() : SequenceDiagram [NullableContext] - Title( title: string ) : SequenceDiagram [NullableContext] @@ -73,40 +110,3 @@ - GenerateDiagramContent() : StringBuilder - GenerateDiagramUrl() : string -## Documentation.TechnicalBlueprint (class) - - ctor() - - Add( - diagrams: params SequenceDiagram[] [ParamArray] - ) : TechnicalBlueprint - - Add( - diagrams: IEnumerable - ) : TechnicalBlueprint - - Intro( - markdown: string - ) : TechnicalBlueprint - - Register() : TechnicalBlueprint - - Register( - interface: Type, - services: IServiceProvider - ) : TechnicalBlueprint - - Register( - interface: Type, - implementation: Type - ) : TechnicalBlueprint - - Render() : string - - TechnicalBlueprint.Titled( - title: string - ) : TechnicalBlueprint - - ToString() : string - -## Documentation.TechnicalBlueprint+DiagramComponents (class) - - ctor() - - Register() : void [NullableContext] - - Register( - interface: Type, - implementation: Type - ) : void - - Resolve( - origin: Type - ) : Type - diff --git a/Contracts/Synergy.Contracts.Test/Architecture/Public/Api.of.Synergy.Contracts.verified.md b/Contracts/Synergy.Contracts.Test/Architecture/Public/Api.of.Synergy.Contracts.verified.md index 4e3ff25..e4217f2 100644 --- a/Contracts/Synergy.Contracts.Test/Architecture/Public/Api.of.Synergy.Contracts.verified.md +++ b/Contracts/Synergy.Contracts.Test/Architecture/Public/Api.of.Synergy.Contracts.verified.md @@ -11,30 +11,30 @@ value: object [CanBeNull, NoEnumeration], name: string [CanBeNull, Optional] ) : T? [Extension, CanBeNull, AssertionMethod, ContractAnnotation] - - Fail.Because( - message: Violation - ) : DesignByContractViolationException [NotNull, Pure] - Fail.Because( message: string [NotNull, NotNull] ) : DesignByContractViolationException [NotNull, Pure, StringFormatMethod] - - Fail.Because( - message: string [NotNull, NotNull], - arg1: T1? - ) : DesignByContractViolationException [NotNull, Pure, StringFormatMethod] - - Fail.Because( + - Fail.Because( message: string [NotNull, NotNull], - arg1: T1?, - arg2: T2? + args: params Object[] [ParamArray, NotNull, NotNull] ) : DesignByContractViolationException [NotNull, Pure, StringFormatMethod] + - Fail.Because( + message: Violation + ) : DesignByContractViolationException [NotNull, Pure] - Fail.Because( message: string [NotNull, NotNull], arg1: T1?, arg2: T2?, arg3: T3? ) : DesignByContractViolationException [NotNull, Pure, StringFormatMethod] - - Fail.Because( + - Fail.Because( message: string [NotNull, NotNull], - args: params Object[] [ParamArray, NotNull, NotNull] + arg1: T1?, + arg2: T2? + ) : DesignByContractViolationException [NotNull, Pure, StringFormatMethod] + - Fail.Because( + message: string [NotNull, NotNull], + arg1: T1? ) : DesignByContractViolationException [NotNull, Pure, StringFormatMethod] - Fail.BecauseEnumOutOfRange( value: T @@ -58,30 +58,30 @@ value: Enum [NotNull, NotNull], name: string [NotNull, NotNull] ) : T? [Extension, NotNull] - - Fail.FailIfNotDate( - date: DateTime? [CanBeNull], - name: string - ) : DateTime?? [Extension, CanBeNull, AssertionMethod] - Fail.FailIfNotDate( date: DateTime, name: string ) : DateTime [Extension, AssertionMethod] + - Fail.FailIfNotDate( + date: DateTime? [CanBeNull], + name: string + ) : DateTime? [Extension, CanBeNull, AssertionMethod] - Fail.FailIfNull( value: T? [CanBeNull, AssertionCondition, NoEnumeration], - name: string [NotNull, NotNull] + message: Violation ) : T? [Extension, NotNull, AssertionMethod, ContractAnnotation] - Fail.FailIfNull( value: T? [CanBeNull, AssertionCondition, NoEnumeration], - message: Violation + name: string [NotNull, NotNull] ) : T? [Extension, NotNull, AssertionMethod, ContractAnnotation] - - Fail.IfArgumentEmpty( - value: Guid, - argumentName: string [NotNull] - ) : void [AssertionMethod] - Fail.IfArgumentEmpty( argumentValue: string [CanBeNull, AssertionCondition], argumentName: string [NotNull, NotNull] ) : void [AssertionMethod, ContractAnnotation] + - Fail.IfArgumentEmpty( + value: Guid, + argumentName: string [NotNull] + ) : void [AssertionMethod] - Fail.IfArgumentEqual( unexpected: TExpected? [CanBeNull], argumentValue: TActual? [CanBeNull], @@ -127,11 +127,11 @@ ) : void [AssertionMethod] - Fail.IfEmpty( value: string [CanBeNull, AssertionCondition], - name: string [NotNull, NotNull] + message: Violation ) : void [AssertionMethod, ContractAnnotation] - Fail.IfEmpty( value: string [CanBeNull, AssertionCondition], - message: Violation + name: string [NotNull, NotNull] ) : void [AssertionMethod, ContractAnnotation] - Fail.IfEnumNotDefined( value: object [NotNull, NotNull] @@ -142,12 +142,12 @@ - Fail.IfEqual( unexpected: TExpected? [CanBeNull], actual: TActual? [CanBeNull], - name: string [NotNull, NotNull] + message: Violation ) : void [AssertionMethod] - Fail.IfEqual( unexpected: TExpected? [CanBeNull], actual: TActual? [CanBeNull], - message: Violation + name: string [NotNull, NotNull] ) : void [AssertionMethod] - Fail.IfFalse( value: bool [AssertionCondition], @@ -164,37 +164,37 @@ ) : void [AssertionMethod] - Fail.IfNotDate( date: DateTime? [CanBeNull], - name: string + message: Violation ) : void [AssertionMethod] - Fail.IfNotDate( date: DateTime? [CanBeNull], - message: Violation + name: string ) : void [AssertionMethod] - Fail.IfNotEqual( expected: TExpected? [CanBeNull], actual: TActual? [CanBeNull], - name: string [NotNull, NotNull] + message: Violation ) : void [AssertionMethod] - Fail.IfNotEqual( expected: TExpected? [CanBeNull], actual: TActual? [CanBeNull], - message: Violation + name: string [NotNull, NotNull] ) : void [AssertionMethod] - Fail.IfNotNull( value: T? [CanBeNull, NoEnumeration], - name: string [NotNull, NotNull] + message: Violation ) : void [AssertionMethod, ContractAnnotation] - Fail.IfNotNull( value: T? [CanBeNull, NoEnumeration], - message: Violation + name: string [NotNull, NotNull] ) : void [AssertionMethod, ContractAnnotation] - Fail.IfNull( value: T? [CanBeNull, AssertionCondition], - name: string [NotNull, NotNull] + message: Violation ) : void [AssertionMethod, ContractAnnotation] - Fail.IfNull( value: T? [CanBeNull, AssertionCondition], - message: Violation + name: string [NotNull, NotNull] ) : void [AssertionMethod, ContractAnnotation] - Fail.IfNullOrNotCastable( value: object [CanBeNull, NoEnumeration] @@ -219,11 +219,11 @@ ) : void [AssertionMethod, ContractAnnotation] - Fail.IfWhitespace( value: string [CanBeNull, AssertionCondition], - name: string [NotNull, NotNull] + message: Violation ) : void [AssertionMethod, ContractAnnotation] - Fail.IfWhitespace( value: string [CanBeNull, AssertionCondition], - message: Violation + name: string [NotNull, NotNull] ) : void [AssertionMethod, ContractAnnotation] - Fail.NotNull( value: T? [CanBeNull, AssertionCondition, NoEnumeration], @@ -255,16 +255,6 @@ name: string [NotNull, NotNull, CallerArgumentExpression, Optional] ) : string [Extension, NotNull, AssertionMethod, ContractAnnotation] -## Violation (struct) - - ctor( - message: string [NotNull, NotNull], - args: params Object[] [ParamArray, NotNull, NotNull] - ) - - Violation.Of( - message: string [NotNull, NotNull], - args: params Object[] [ParamArray, NotNull, NotNull] - ) : Violation [StringFormatMethod] - ## Requirements.Business (abstract class) - Business.Requires( condition: bool @@ -277,12 +267,8 @@ expression: string? [CallerArgumentExpression, Optional] ) : Business+Precondition [NullableContext, MustUseReturnValue] -## Requirements.BusinessRuleViolationException (exception) : Exception, ISerializable - - Requirement: Business+Requirement { get; } - - ctor( - message: string, - requirement: Business+Requirement - ) +## Requirements.Business+IPrecondition (interface) + - Met: bool { get; } ## Requirements.Business+Precondition (struct) : Business+IPrecondition - Comment: string [CanBeNull] { get; } @@ -303,8 +289,20 @@ condition: Func ) : Business+Requirement [MustUseReturnValue] -## Requirements.Business+IPrecondition (interface) - - Met: bool { get; } +## Requirements.Business+Principle (struct) + - Description: string { get; } + - ctor( + description: string + ) + - Requires( + condition: bool + ) : Business+Requirement [MustUseReturnValue] + - Throws( + exception: Exception + ) : void + - When( + preCondition: bool + ) : Business+Precondition [MustUseReturnValue] ## Requirements.Business+Requirement (struct) - Comment: string [CanBeNull] { get; } @@ -323,24 +321,26 @@ comment: string [CanBeNull, Optional] ) - Throws( - message: string + exception: Exception ) : void - Throws( - exception: Exception + message: string ) : void -## Requirements.Business+Principle (struct) - - Description: string { get; } +## Requirements.BusinessRuleViolationException (exception) : Exception, ISerializable + - Requirement: Business+Requirement { get; } - ctor( - description: string + message: string, + requirement: Business+Requirement ) - - Requires( - condition: bool - ) : Business+Requirement [MustUseReturnValue] - - Throws( - exception: Exception - ) : void - - When( - preCondition: bool - ) : Business+Precondition [MustUseReturnValue] + +## Violation (struct) + - ctor( + message: string [NotNull, NotNull], + args: params Object[] [ParamArray, NotNull, NotNull] + ) + - Violation.Of( + message: string [NotNull, NotNull], + args: params Object[] [ParamArray, NotNull, NotNull] + ) : Violation [StringFormatMethod] diff --git a/Documentation/Synergy.Documentation.Tests/Architecture/Public/Api.of.Synergy.Documentation.verified.md b/Documentation/Synergy.Documentation.Tests/Architecture/Public/Api.of.Synergy.Documentation.verified.md index a2a64e6..490f029 100644 --- a/Documentation/Synergy.Documentation.Tests/Architecture/Public/Api.of.Synergy.Documentation.verified.md +++ b/Documentation/Synergy.Documentation.Tests/Architecture/Public/Api.of.Synergy.Documentation.verified.md @@ -1,38 +1,40 @@ # Synergy.Documentation -## Todos.TodoExplorer (abstract class) - - TodoExplorer.DebtFor( - name: string, - from: CodeFolder, - currentPath: string [CallerFilePath, Optional], - patterns: params TodoPattern[] [ParamArray] +## Api.ApiDescription (abstract class) + - ApiDescription.For( + method: MethodInfo, + withAttributes: bool [Optional] + ) : string + - ApiDescription.GenerateFor( + assembly: Assembly + ) : string + - ApiDescription.GenerateFor( + types: IEnumerable, + description: StringBuilder? [Nullable, Optional], + assemblyName: string? [Nullable, Optional] + ) : string + - ApiDescription.GetTypeName( + method: MethodInfo + ) : string + - ApiDescription.GetTypeName( + parameter: ParameterInfo + ) : string + - ApiDescription.GetTypeName( + type: Type ) : string -## Todos.Patterns.CsharpTodoPattern (record) : TodoPattern, IEquatable, IEquatable - - FileExtension: string { get; set; } - - Regex: Regex { get; set; } - - TodoExtractor: Func { get; set; } - - ctor() - -## Todos.Patterns.GherkinTodoPattern (record) : TodoPattern, IEquatable, IEquatable - - FileExtension: string { get; set; } - - Regex: Regex { get; set; } - - TodoExtractor: Func { get; set; } - - ctor() - -## Todos.Patterns.TextTodoPattern (record) : TodoPattern, IEquatable, IEquatable - - FileExtension: string { get; set; } - - Regex: Regex { get; set; } - - TodoExtractor: Func { get; set; } - - ctor() - -## Todos.Patterns.TodoPattern (abstract class) : IEquatable - - FileExtension: string { get; set; } - - Regex: Regex { get; set; } - - TodoExtractor: Func { get; set; } - -## Markup.Markdown (class) - - ctor() +## Api.ClassDocumentation (class) : Markdown+Document, IEnumerable, IEnumerable + - ctor( + type: Type + ) + - Append( + element: Markdown+IElement + ) : Markdown+Document + - Append( + newElements: IEnumerable + ) : Markdown+Document + - GetEnumerator() : IEnumerator + - ToString() : string ## Code.ClassReader (class) - ctor() @@ -74,43 +76,18 @@ jumps: int [Optional] ) : CodeFolder -## Api.ApiDescription (abstract class) - - ApiDescription.For( - method: MethodInfo, - withAttributes: bool [Optional] - ) : string - - ApiDescription.GenerateFor( - assembly: Assembly - ) : string - - ApiDescription.GenerateFor( - types: IEnumerable, - description: StringBuilder? [Nullable, Optional], - assemblyName: string? [Nullable, Optional] - ) : string - - ApiDescription.GetTypeName( - method: MethodInfo - ) : string - - ApiDescription.GetTypeName( - parameter: ParameterInfo - ) : string - - ApiDescription.GetTypeName( - type: Type - ) : string +## Markup.Markdown (class) + - ctor() -## Api.ClassDocumentation (class) : Markdown+Document, IEnumerable, IEnumerable +## Markup.Markdown+Code (class) : Markdown+IElement - ctor( - type: Type + text: string? [Optional], + language: string? [Optional] ) - - Append( - element: Markdown+IElement - ) : Markdown+Document - - Append( - newElements: IEnumerable - ) : Markdown+Document - - GetEnumerator() : IEnumerator - - ToString() : string - -## Markup.Markdown+IElement (interface) + - Line( + line: string + ) : Markdown+Code [NullableContext] + - ToString() : string [NullableContext] ## Markup.Markdown+Document (class) : IEnumerable, IEnumerable - ctor() @@ -144,15 +121,27 @@ ) - ToString() : string -## Markup.Markdown+Code (class) : Markdown+IElement +## Markup.Markdown+IElement (interface) + +## Markup.Markdown+Image (class) : Markdown+IElement - ctor( - text: string? [Optional], - language: string? [Optional] + filePath: CodeFile, + alternateText: string? [Nullable, Optional] ) - - Line( - line: string - ) : Markdown+Code [NullableContext] - - ToString() : string [NullableContext] + - RelativeTo( + file: CodeFile + ) : Markdown+Image + - ToString() : string + +## Markup.Markdown+Link (class) + - ctor( + filePath: CodeFile, + text: string? [Nullable, Optional] + ) + - RelativeTo( + file: CodeFile + ) : Markdown+Link + - ToString() : string ## Markup.Markdown+Paragraph (class) : Markdown+IElement - ctor( @@ -181,13 +170,34 @@ ) : void - ToString() : string -## Markup.Markdown+Image (class) : Markdown+IElement - - ctor( - filePath: CodeFile, - alternateText: string? [Nullable, Optional] - ) - - RelativeTo( - file: CodeFile - ) : Markdown+Image - - ToString() : string +## Todos.Patterns.CsharpTodoPattern (record) : TodoPattern, IEquatable, IEquatable + - FileExtension: string { get; set; } + - Regex: Regex { get; set; } + - TodoExtractor: Func { get; set; } + - ctor() + +## Todos.Patterns.GherkinTodoPattern (record) : TodoPattern, IEquatable, IEquatable + - FileExtension: string { get; set; } + - Regex: Regex { get; set; } + - TodoExtractor: Func { get; set; } + - ctor() + +## Todos.Patterns.TextTodoPattern (record) : TodoPattern, IEquatable, IEquatable + - FileExtension: string { get; set; } + - Regex: Regex { get; set; } + - TodoExtractor: Func { get; set; } + - ctor() + +## Todos.Patterns.TodoPattern (abstract class) : IEquatable + - FileExtension: string { get; set; } + - Regex: Regex { get; set; } + - TodoExtractor: Func { get; set; } + +## Todos.TodoExplorer (abstract class) + - TodoExplorer.DebtFor( + name: string, + from: CodeFolder, + currentPath: string [CallerFilePath, Optional], + patterns: params TodoPattern[] [ParamArray] + ) : string diff --git a/Documentation/Synergy.Documentation/Api/ApiDescription.cs b/Documentation/Synergy.Documentation/Api/ApiDescription.cs index 451fd8f..a03b460 100644 --- a/Documentation/Synergy.Documentation/Api/ApiDescription.cs +++ b/Documentation/Synergy.Documentation/Api/ApiDescription.cs @@ -20,19 +20,25 @@ public static string GenerateFor(Assembly assembly) var assemblyName = assembly.GetName().Name; description.AppendLine($"# {assemblyName}"); description.AppendLine(); - - return GenerateFor(assembly.GetTypes(), description, assemblyName); + + var publicTypes = assembly + .GetTypes() + .Where(type => type.IsPublic || type.IsNestedPublic) + .OrderBy(t => t.FullName); + + return GenerateFor(publicTypes, description, assemblyName); } - public static string GenerateFor(IEnumerable types, StringBuilder? description = null, string? assemblyName = null) + public static string GenerateFor( + IEnumerable types, + StringBuilder? description = null, + string? assemblyName = null + ) { description ??= new StringBuilder(); foreach (var type in types) { - if (type.IsPublic == false && type.IsNestedPublic == false) - continue; - var shortNamespace = GetShortenNamespace(type, assemblyName); var typeName = GetShortTypeName(type); var baseType = GetParents(type); @@ -69,22 +75,9 @@ public static string GenerateFor(IEnumerable types, StringBuilder? descrip description.AppendLine($" - ctor({GetParametersOf(constructor)})"); } - foreach (var method in type.GetMethods(bindingFlags).OrderBy(m => m.Name)) + foreach (var method in GetMethods(type).OrderBy(m => m)) { - if (method.IsSpecialName || method.DeclaringType.In(typeof(object), typeof(Exception), typeof(Attribute))) - continue; - - if (type.IsValueType && method.Name.In(nameof(Equals), nameof(GetHashCode), nameof(ToString))) - continue; - - if (method.GetCustomAttribute() != null) - continue; - - if (type.IsRecord() && method.Name.In(nameof(ToString), nameof(GetHashCode), nameof(Equals), "$", "Deconstruct")) - continue; - - var methodDescription = For(method); - description.AppendLine($" - {methodDescription}"); + description.AppendLine($" - {method}"); } } @@ -94,6 +87,26 @@ public static string GenerateFor(IEnumerable types, StringBuilder? descrip return description.ToString(); } + private static IEnumerable GetMethods(Type type) + { + foreach (var method in type.GetMethods(bindingFlags).OrderBy(m => m.Name)) + { + if (method.IsSpecialName || method.DeclaringType.In(typeof(object), typeof(Exception), typeof(Attribute))) + continue; + + if (type.IsValueType && method.Name.In(nameof(Equals), nameof(GetHashCode), nameof(ToString))) + continue; + + if (method.GetCustomAttribute() != null) + continue; + + if (type.IsRecord() && method.Name.In(nameof(ToString), nameof(GetHashCode), nameof(Equals), "$", "Deconstruct")) + continue; + + yield return For(method); + } + } + public static string For(MethodInfo method, bool withAttributes = true) { var generics = method.GetGenericArguments(); @@ -174,7 +187,7 @@ private static bool In(this T value, params T[] values) private static bool NotIn(this T value, params T[] values) => value.In(values) == false; - internal static string GetMethodName(MethodInfo method) + private static string GetMethodName(MethodInfo method) { if (method.IsStatic) return $"{method.DeclaringType.Name}.{method.Name}"; @@ -225,8 +238,8 @@ private static string GetParametersOf(MethodInfo method, bool withAttributes = t return ""; var last = parameters.Last(); - StringBuilder description = new StringBuilder(); - foreach (ParameterInfo parameter in parameters) + var description = new StringBuilder(); + foreach (var parameter in parameters) { description.AppendLine(); var attributes = withAttributes ? GetAttributes(parameter) : ""; @@ -245,7 +258,7 @@ private static string GetTypeName(PropertyInfo property) var type = GetTypeName(property.PropertyType); var nullable = IsMarkedAsNullable(property); if (nullable) - return type + "?"; + return type.TrimEnd('?') + "?"; return type; } @@ -258,7 +271,7 @@ private static string GetTypeName(FieldInfo field) var type = GetTypeName(field.FieldType); var nullable = IsMarkedAsNullable(field); if (nullable) - return type + "?"; + return type.TrimEnd('?') + "?"; return type; } @@ -271,7 +284,7 @@ public static string GetTypeName(MethodInfo method) var type = GetTypeName(method.ReturnType); var nullable = IsMarkedAsNullable(method.ReturnParameter); if (nullable) - return type + "?"; + return type.TrimEnd('?') + "?"; return type; } @@ -301,9 +314,10 @@ public static string GetTypeName(ParameterInfo parameter) public static string GetTypeName(Type type) { - if (Nullable.GetUnderlyingType(type) != null) + var underlyingType = Nullable.GetUnderlyingType(type); + if (underlyingType != null) { - return $"{GetTypeName(Nullable.GetUnderlyingType(type))}?"; + return $"{GetTypeName(underlyingType)}?"; } if (type.IsGenericType) @@ -354,7 +368,8 @@ private static string GetAttributes(ParameterInfo parameter) private static string GetAttributes(IEnumerable enumerable) { - var attributes = enumerable.Where(a => a.GetType().Name.StartsWith("__") == false) + var attributes = enumerable + .Where(a => a.GetType().Name.StartsWith("__") == false) .Where(a => a is not DebuggerStepThroughAttribute) .Select(a => a.GetType().Name.Replace("Attribute", "")) .ToList(); diff --git a/Web/Synergy.Web.Api.Tests/Architecture/Public/Api.of.Synergy.Web.Api.Testing.verified.md b/Web/Synergy.Web.Api.Tests/Architecture/Public/Api.of.Synergy.Web.Api.Testing.verified.md index 471f3e6..2aa55e6 100644 --- a/Web/Synergy.Web.Api.Tests/Architecture/Public/Api.of.Synergy.Web.Api.Testing.verified.md +++ b/Web/Synergy.Web.Api.Tests/Architecture/Public/Api.of.Synergy.Web.Api.Testing.verified.md @@ -1,238 +1,25 @@ # Synergy.Web.Api.Testing -## HttpExtensions (abstract class) - - HttpExtensions.GetAllHeaders( - response: HttpResponseMessage - ) : List>> [Extension] - - HttpExtensions.GetAllRequestHeaders( - operation: HttpOperation - ) : List>> [Extension] - - HttpExtensions.Read( - content: HttpContent? [NotNull], - jsonPath: string [Nullable], - value: out T& [Nullable, Out] - ) : HttpContent? [NullableContext, Extension, MustUseReturnValue] - - HttpExtensions.Read( - content: HttpContent? [NotNull] - ) : T [NullableContext, Extension] - - HttpExtensions.Read( - content: HttpContent? [Nullable, NotNull], - jsonPath: string - ) : T? [Extension, MustUseReturnValue] - - HttpExtensions.ReadJson( - content: HttpContent? [CanBeNull] - ) : JToken? [NullableContext, Extension, MustUseReturnValue] - - HttpExtensions.ToHttpLook( - request: HttpRequestMessage, - operation: HttpOperation - ) : string [Extension] - - HttpExtensions.ToHttpLook( - response: HttpResponseMessage, - operation: HttpOperation - ) : string [Extension, NotNull] - -## HttpOperation (class) - - Description: string? [Nullable, CanBeNull] { get; } - - Duration: TimeSpan { get; } - - Request: HttpRequestMessage { get; } - - Response: HttpResponseMessage { get; } - - TestServer: TestServer { get; } - - Assertions: List (field) - - ctor() - -## HttpOperationExtensions (abstract class) - - HttpOperationExtensions.Details( - operation: TOperation, - details: string - ) : TOperation [Extension] - - HttpOperationExtensions.ShouldBe( - operation: TOperation, - assertion: IAssertion - ) : TOperation [Extension] - - HttpOperationExtensions.ShouldBe( - operation: TOperation, - assertions: IEnumerable - ) : TOperation [Extension] - -## TestServer (abstract class) : IDisposable - - HttpClient: HttpClient [NotNull] { get; } - - Repair: bool { get; set; } - - SerializationSettings: JsonSerializerSettings { get; } - - Delete( - path: string, - urlParameters: object? [Nullable, Optional], - body: object? [Nullable, Optional], - headers: Action? [Nullable, Optional] - ) : HttpOperation - - Delete( - path: string, - urlParameters: object? [Nullable, Optional], - body: object? [Nullable, Optional], - headers: Action? [Nullable, Optional] - ) : TOperation - - Dispose() : void - - FailIfLeftInRepairMode() : void - - Get( - path: string, - urlParameters: object? [Nullable, Optional], - headers: Action? [Nullable, Optional] - ) : HttpOperation - - Get( - path: string, - urlParameters: object? [Nullable, Optional], - headers: Action? [Nullable, Optional] - ) : TOperation - - Patch( - path: string, - urlParameters: object? [Nullable, Optional], - body: object? [Nullable, Optional], - headers: Action? [Nullable, Optional] - ) : HttpOperation - - Patch( - path: string, - urlParameters: object? [Nullable, Optional], - body: object? [Nullable, Optional], - headers: Action? [Nullable, Optional] - ) : TOperation - - Post( - path: string, - urlParameters: object? [Nullable, Optional], - body: object? [Nullable, Optional], - headers: Action? [Nullable, Optional] - ) : HttpOperation - - Post( - path: string, - urlParameters: object? [Nullable, Optional], - body: object? [Nullable, Optional], - headers: Action? [Nullable, Optional] - ) : TOperation - - Post( - path: string, - urlParameters: object? [Nullable, Optional], - body: JToken [Optional], - headers: Action? [Nullable, Optional] - ) : HttpOperation - - Put( - path: string, - urlParameters: object? [Nullable, Optional], - body: object? [Nullable, Optional], - headers: Action? [Nullable, Optional] - ) : HttpOperation - - Put( - path: string, - urlParameters: object? [Nullable, Optional], - body: object? [Nullable, Optional], - headers: Action? [Nullable, Optional] - ) : TOperation - -## Json.Ignore (class) - - Nodes: ReadOnlyCollection { get; } - - ctor( - nodes: params String[] [ParamArray] - ) - - And( - ignore: Ignore - ) : Ignore - - Append( - ignores: IEnumerable - ) : void - - Ignore.RequestDescription() : Ignore - - Ignore.RequestMethod() : Ignore - - Ignore.ResponseBody( - nodes: params String[] [ParamArray] - ) : Ignore - - Ignore.ResponseContentLength() : Ignore - - Ignore.ResponseLocationHeader() : Ignore - -## Json.JsonComparer (class) - - AreEquivalent: bool { get; } - - Ignore: Ignore { get; } - - New: JToken { get; } - - Pattern: JToken { get; } - - ctor( - pattern: JToken, - new: JToken, - ignore: Ignore? [Nullable, Optional] - ) - - GetDifferences( - maxNoOfDifferences: int [Optional] - ) : string? [NullableContext] - -## Features.Feature (class) - - Scenarios: List { get; } - - Title: string [NotNull] { get; } - - ctor( - title: string [NotNull] - ) - - Scenario( - title: string [NotNull] - ) : Scenario [NotNull] - -## Features.FeatureExtensions (abstract class) - - FeatureExtensions.InStep( - operation: TOperation [NotNull], - step: Step [NotNull] - ) : TOperation [NullableContext, Extension] - -## Features.IExpectation (interface) - - ExpectedResult: string { get; } - -## Features.IHttpRequestStorage (interface) - - GetSavedRequest() : HttpRequestMessage - -## Features.IHttpResponseStorage (interface) - - GetSavedResponse() : HttpResponseMessage - -## Features.Markdown (class) - - ctor( - feature: Feature - ) - - GenerateReportTo( - filePath: string? [Nullable, Optional] - ) : string - -## Features.Scenario (class) - - No: int { get; } - - Steps: List { get; } - - Title: string [NotNull] { get; } - - ctor( - title: string [NotNull], - no: int - ) - - Step( - title: string [NotNull] - ) : Step [NotNull] - -## Features.Step (class) - - Content: string? [Nullable] { get; } - - No: int { get; } - - Title: string { get; } - - Operations: List (field) - - ctor( - title: string, - no: int - ) - - Markdown( - markdown: string - ) : void - ## Assertions.Assertion (abstract class) : IAssertion, IExpectation - ExpectedResult: string? [Nullable] { get; } - Assertion.Ok: Assertion+Result { get; } - Assert( operation: HttpOperation ) : Assertion+Result - - Expected( - expected: string - ) : IAssertion - Assertion.Failure( message: string ) : Assertion+Result + - Expected( + expected: string + ) : IAssertion -## Assertions.IAssertion (interface) : IExpectation - - Assert( - operation: HttpOperation - ) : Assertion+Result [NullableContext] +## Assertions.Assertion+Result (struct) + - IsOk: bool { get; } + - Message: string { get; } + - Result.Ok: Assertion+Result { get; } + - ctor( + message: string [NotNull] + ) ## Assertions.CompareOperationWithPattern (class) : Assertion, IAssertion, IExpectation, IHttpRequestStorage, IHttpResponseStorage - ExpectedResult: string? [Nullable] { get; } @@ -244,18 +31,18 @@ - Assert( operation: HttpOperation ) : Assertion+Result - - Expected( - expected: string - ) : IAssertion - Assertion.Failure( message: string ) : Assertion+Result + - Expected( + expected: string + ) : IAssertion - Ignore( - ignore: string, - ignores: params String[] [ParamArray] + ignore: Ignore ) : CompareOperationWithPattern - Ignore( - ignore: Ignore + ignore: string, + ignores: params String[] [ParamArray] ) : CompareOperationWithPattern ## Assertions.CompareResponseWithPattern (class) : Assertion, IAssertion, IExpectation @@ -269,12 +56,21 @@ - Assert( operation: HttpOperation ) : Assertion+Result - - Expected( - expected: string - ) : IAssertion - Assertion.Failure( message: string ) : Assertion+Result + - Expected( + expected: string + ) : IAssertion + +## Assertions.CompareResponseWithPattern+Mode (enum) : IComparable, IFormattable, IConvertible + - ContractCheck = 1 + - Default = 2 + +## Assertions.IAssertion (interface) : IExpectation + - Assert( + operation: HttpOperation + ) : Assertion+Result [NullableContext] ## Assertions.VerifyRequestMethod (class) : Assertion, IAssertion, IExpectation - ExpectedResult: string? [Nullable] { get; } @@ -285,12 +81,12 @@ - Assert( operation: HttpOperation ) : Assertion+Result - - Expected( - expected: string - ) : IAssertion - Assertion.Failure( message: string ) : Assertion+Result + - Expected( + expected: string + ) : IAssertion ## Assertions.VerifyResponseBody (class) : Assertion, IAssertion, IExpectation - ExpectedResult: string? [Nullable] { get; } @@ -302,12 +98,12 @@ - Assert( operation: HttpOperation ) : Assertion+Result - - Expected( - expected: string - ) : IAssertion - Assertion.Failure( message: string ) : Assertion+Result + - Expected( + expected: string + ) : IAssertion ## Assertions.VerifyResponseContentType (class) : Assertion, IAssertion, IExpectation - ExpectedResult: string? [Nullable] { get; } @@ -318,12 +114,12 @@ - Assert( operation: HttpOperation ) : Assertion+Result - - Expected( - expected: string - ) : IAssertion - Assertion.Failure( message: string ) : Assertion+Result + - Expected( + expected: string + ) : IAssertion ## Assertions.VerifyResponseHeader (class) : Assertion, IAssertion, IExpectation - ExpectedResult: string? [Nullable] { get; } @@ -335,12 +131,12 @@ - Assert( operation: HttpOperation ) : Assertion+Result - - Expected( - expected: string - ) : IAssertion - Assertion.Failure( message: string ) : Assertion+Result + - Expected( + expected: string + ) : IAssertion ## Assertions.VerifyResponseStatus (class) : Assertion, IAssertion, IExpectation - ExpectedResult: string? [Nullable] { get; } @@ -351,27 +147,231 @@ - Assert( operation: HttpOperation ) : Assertion+Result [NullableContext] - - Expected( - expected: string - ) : IAssertion - Assertion.Failure( message: string ) : Assertion+Result + - Expected( + expected: string + ) : IAssertion ## Assertions.WebApiRuleViolationException (exception) : Exception, ISerializable - ctor( result: Assertion+Result ) -## Assertions.Assertion+Result (struct) - - IsOk: bool { get; } - - Message: string { get; } - - Result.Ok: Assertion+Result { get; } +## Features.Feature (class) + - Scenarios: List { get; } + - Title: string [NotNull] { get; } - ctor( - message: string [NotNull] + title: string [NotNull] ) + - Scenario( + title: string [NotNull] + ) : Scenario [NotNull] -## Assertions.CompareResponseWithPattern+Mode (enum) : IComparable, IFormattable, IConvertible - - ContractCheck = 1 - - Default = 2 +## Features.FeatureExtensions (abstract class) + - FeatureExtensions.InStep( + operation: TOperation [NotNull], + step: Step [NotNull] + ) : TOperation [NullableContext, Extension] + +## Features.IExpectation (interface) + - ExpectedResult: string { get; } + +## Features.IHttpRequestStorage (interface) + - GetSavedRequest() : HttpRequestMessage + +## Features.IHttpResponseStorage (interface) + - GetSavedResponse() : HttpResponseMessage + +## Features.Markdown (class) + - ctor( + feature: Feature + ) + - GenerateReportTo( + filePath: string? [Nullable, Optional] + ) : string + +## Features.Scenario (class) + - No: int { get; } + - Steps: List { get; } + - Title: string [NotNull] { get; } + - ctor( + title: string [NotNull], + no: int + ) + - Step( + title: string [NotNull] + ) : Step [NotNull] + +## Features.Step (class) + - Content: string? [Nullable] { get; } + - No: int { get; } + - Title: string { get; } + - Operations: List (field) + - ctor( + title: string, + no: int + ) + - Markdown( + markdown: string + ) : void + +## HttpExtensions (abstract class) + - HttpExtensions.GetAllHeaders( + response: HttpResponseMessage + ) : List>> [Extension] + - HttpExtensions.GetAllRequestHeaders( + operation: HttpOperation + ) : List>> [Extension] + - HttpExtensions.Read( + content: HttpContent? [NotNull] + ) : T [NullableContext, Extension] + - HttpExtensions.Read( + content: HttpContent? [NotNull], + jsonPath: string [Nullable], + value: out T& [Nullable, Out] + ) : HttpContent? [NullableContext, Extension, MustUseReturnValue] + - HttpExtensions.Read( + content: HttpContent? [Nullable, NotNull], + jsonPath: string + ) : T? [Extension, MustUseReturnValue] + - HttpExtensions.ReadJson( + content: HttpContent? [CanBeNull] + ) : JToken? [NullableContext, Extension, MustUseReturnValue] + - HttpExtensions.ToHttpLook( + request: HttpRequestMessage, + operation: HttpOperation + ) : string [Extension] + - HttpExtensions.ToHttpLook( + response: HttpResponseMessage, + operation: HttpOperation + ) : string [Extension, NotNull] + +## HttpOperation (class) + - Description: string? [Nullable, CanBeNull] { get; } + - Duration: TimeSpan { get; } + - Request: HttpRequestMessage { get; } + - Response: HttpResponseMessage { get; } + - TestServer: TestServer { get; } + - Assertions: List (field) + - ctor() + +## HttpOperationExtensions (abstract class) + - HttpOperationExtensions.Details( + operation: TOperation, + details: string + ) : TOperation [Extension] + - HttpOperationExtensions.ShouldBe( + operation: TOperation, + assertion: IAssertion + ) : TOperation [Extension] + - HttpOperationExtensions.ShouldBe( + operation: TOperation, + assertions: IEnumerable + ) : TOperation [Extension] + +## Json.Ignore (class) + - Nodes: ReadOnlyCollection { get; } + - ctor( + nodes: params String[] [ParamArray] + ) + - And( + ignore: Ignore + ) : Ignore + - Append( + ignores: IEnumerable + ) : void + - Ignore.RequestDescription() : Ignore + - Ignore.RequestMethod() : Ignore + - Ignore.ResponseBody( + nodes: params String[] [ParamArray] + ) : Ignore + - Ignore.ResponseContentLength() : Ignore + - Ignore.ResponseLocationHeader() : Ignore + +## Json.JsonComparer (class) + - AreEquivalent: bool { get; } + - Ignore: Ignore { get; } + - New: JToken { get; } + - Pattern: JToken { get; } + - ctor( + pattern: JToken, + new: JToken, + ignore: Ignore? [Nullable, Optional] + ) + - GetDifferences( + maxNoOfDifferences: int [Optional] + ) : string? [NullableContext] + +## TestServer (abstract class) : IDisposable + - HttpClient: HttpClient [NotNull] { get; } + - Repair: bool { get; set; } + - SerializationSettings: JsonSerializerSettings { get; } + - Delete( + path: string, + urlParameters: object? [Nullable, Optional], + body: object? [Nullable, Optional], + headers: Action? [Nullable, Optional] + ) : HttpOperation + - Delete( + path: string, + urlParameters: object? [Nullable, Optional], + body: object? [Nullable, Optional], + headers: Action? [Nullable, Optional] + ) : TOperation + - Dispose() : void + - FailIfLeftInRepairMode() : void + - Get( + path: string, + urlParameters: object? [Nullable, Optional], + headers: Action? [Nullable, Optional] + ) : HttpOperation + - Get( + path: string, + urlParameters: object? [Nullable, Optional], + headers: Action? [Nullable, Optional] + ) : TOperation + - Patch( + path: string, + urlParameters: object? [Nullable, Optional], + body: object? [Nullable, Optional], + headers: Action? [Nullable, Optional] + ) : HttpOperation + - Patch( + path: string, + urlParameters: object? [Nullable, Optional], + body: object? [Nullable, Optional], + headers: Action? [Nullable, Optional] + ) : TOperation + - Post( + path: string, + urlParameters: object? [Nullable, Optional], + body: JToken [Optional], + headers: Action? [Nullable, Optional] + ) : HttpOperation + - Post( + path: string, + urlParameters: object? [Nullable, Optional], + body: object? [Nullable, Optional], + headers: Action? [Nullable, Optional] + ) : HttpOperation + - Post( + path: string, + urlParameters: object? [Nullable, Optional], + body: object? [Nullable, Optional], + headers: Action? [Nullable, Optional] + ) : TOperation + - Put( + path: string, + urlParameters: object? [Nullable, Optional], + body: object? [Nullable, Optional], + headers: Action? [Nullable, Optional] + ) : HttpOperation + - Put( + path: string, + urlParameters: object? [Nullable, Optional], + body: object? [Nullable, Optional], + headers: Action? [Nullable, Optional] + ) : TOperation