fslang-design icon indicating copy to clipboard operation
fslang-design copied to clipboard

[style-guide] Multiline base constructor call

Open nojaf opened this issue 3 years ago • 0 comments

How would the style guide envision the following inherit function calls are formatted?

type UnhandledWebException =
    inherit Exception

    new(status: WebExceptionStatus, innerException: Exception) =
        { inherit Exception(SPrintF1
                                "Backend not prepared for this WebException with Status[%i]"
                                (int status),
                            innerException) }

    new(info: SerializationInfo, context: StreamingContext) =
        { inherit Exception(info, context) }

type FieldNotFoundException<'T>(obj: 'T, field: string, specLink: string) =
    inherit SwaggerSchemaParseException(sprintf
                                            "Object MUST contain field `%s` (See %s for more details).\nObject:%A"
                                            field
                                            specLink
                                            obj)

Should the expressions after the inherit follow the same rules as https://docs.microsoft.com/en-us/dotnet/fsharp/style-guide/formatting#formatting-application-expressions?

Something like

type UnhandledWebException =
    inherit Exception

    new(status: WebExceptionStatus, innerException: Exception) =
        { inherit
            Exception(
                SPrintF1 "Backend not prepared for this WebException with Status[%i]" (int status),
                innerException
            ) }

    new(info: SerializationInfo, context: StreamingContext) = { inherit Exception(info, context) }

type FieldNotFoundException<'T>(obj: 'T, field: string, specLink: string) =
    inherit 
        SwaggerSchemaParseException(
            sprintf
                "Object MUST contain field `%s` (See %s for more details).\nObject:%A"
                field
                specLink
                obj
        )

?

Adding the extra indent and new line after inherit would allow for the "indentation flow" to be preserved.

Thoughts?

nojaf avatar Jul 08 '22 15:07 nojaf