Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiline secondary constructor #3037

Closed
4 tasks
MangelMaxime opened this issue Jan 11, 2024 · 4 comments · Fixed by #3038
Closed
4 tasks

Multiline secondary constructor #3037

MangelMaxime opened this issue Jan 11, 2024 · 4 comments · Fixed by #3038

Comments

@MangelMaxime
Copy link

Issue created from fantomas-online

Code

type IntersectionOptions
    private
    (
        primary: bool,
        ?root: Element,
        ?rootMargin: string,
        ?threshold: ResizeArray<float>,
        ?triggerOnce: bool
    )
    =

    new(?root: Element,
        ?rootMargin: string,
        ?threshold: ResizeArray<float>,
        ?triggerOnce: bool) =

        IntersectionOptions(true)

    static member Test
        (
            ?root: Element,
            ?rootMargin: string,
            ?threshold: ResizeArray<float>,
            ?triggerOnce: bool
        )
        =
        failwith "Not implemented"

Result

type IntersectionOptions
    private
    (
        primary: bool,
        ?root: Element,
        ?rootMargin: string,
        ?threshold: ResizeArray<float>,
        ?triggerOnce: bool
    ) =

    new(?root: Element,
        ?rootMargin: string,
        ?threshold: ResizeArray<float>,
        ?triggerOnce: bool) =

        IntersectionOptions(true)

    static member Test
        (
            ?root: Element,
            ?rootMargin: string,
            ?threshold: ResizeArray<float>,
            ?triggerOnce: bool
        ) =
        failwith "Not implemented"

Problem description

Please describe here the Fantomas problem you encountered.
Check out our Contribution Guidelines.

The secondary constructors should follows the same indentation styles as the primary constructor and the member declaration.

type IntersectionOptions
	// ...
    =
	
    new
        (
            ?root: Element,
            ?rootMargin: string,
            ?threshold: ResizeArray<float>,
            ?triggerOnce: bool
        ) =

        IntersectionOptions(true)
	
	// ...

Extra information

  • The formatted result breaks my code.
  • The formatted result gives compiler warnings.
  • I or my company would be willing to help fix this.
  • I would like a release if this problem is solved.

Options

Fantomas main branch at 2024-01-11T10:58:46Z - d8f44db

    { config with
                MaxLineLength = 80
                MultilineBracketStyle = stroustrup }

Did you know that you can ignore files when formatting by using a .fantomasignore file?
PS: It's unlikely that someone else will solve your specific issue, as it's something that you have a personal stake in.

@nojaf
Copy link
Contributor

nojaf commented Jan 11, 2024

The current situation is that the formatting for implicit constructors is not influenced by the MultilineBracketStyle setting. So it gap is more with secondary constructors in general.

I'm open to implementing this feature, but I would like it to be clearly explained in the style guide. While I believe there's no need for extensive discussion on this matter, updating the guide on dotnet/docs could be beneficial in preemptively addressing any potential concerns from the community.

Could you send over a PR for the style guide?

@MangelMaxime
Copy link
Author

I'm open to implementing this feature, but I would like it to be clearly explained in the style guide. While I believe there's no need for extensive discussion on this matter, updating the guide on dotnet/docs could be beneficial in preemptively addressing any potential concerns from the community.

Indeed, I think this case is cover by this section to be more precise this paragraph:

CleanShot 2024-01-11 at 16 22 11@2x

I can send a PR to add an exemple for secondary constructors.

@nojaf
Copy link
Contributor

nojaf commented Jan 11, 2024

I can send a PR to add an exemple for secondary constructors.

Thanks!

@nojaf nojaf changed the title Secondary constructor doesn't follow MultilineBracketStyle Multiline secondary constructor Jan 12, 2024
@nojaf
Copy link
Contributor

nojaf commented Jan 27, 2024

Available in https://www.nuget.org/packages/fantomas/6.3.0-alpha-007

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants