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

How to have a multiline value #481

Open
Youssef1313 opened this issue Jan 1, 2023 · 6 comments
Open

How to have a multiline value #481

Youssef1313 opened this issue Jan 1, 2023 · 6 comments

Comments

@Youssef1313
Copy link

See editorconfig/specification#35

Per the current specification, I don't see how (if possible) to include a key-value pair whose value is a multiline string.

If it's not currently possible, is it possible to update the spec to have a way for that?

@cxw42
Copy link
Member

cxw42 commented Jan 3, 2023

Thanks for using EC! Could you give us a sample use case? What key are you using, and what would a sample multiline value be?

@Youssef1313
Copy link
Author

@cxw42 It will be usefuly for the C# compiler. (Note: I'm not a Microsoft employee, but a regular contributor to Roslyn)

In short, the C# compiler currently uses .editorconfig files to parse analyzer options. Most of the time these are single-line key-value pairs, e.g, dotnet_diagnostic.CA1822.severity = warning.

However, MSBuild properties (xml-based) can be passed to the compiler, for that, there is a build task that converts the "compiler visible" MSBuild properties to an .editorconfig during compile-time.

MSBuild property values can be multiline, and here comes the problem.

See issue: dotnet/roslyn#43970

@cxw42
Copy link
Member

cxw42 commented Jan 6, 2023

Thanks for the additional information! I see the linked issue gives this example (I added {{ }} around the desired property value):

is_global = true
msbuild_property.PropWithNewLine = {{this
is 
a
valid = property}}

The linked issue talks about "global analyzer configs" --- would the multiline properties be consumed by editors or other tools?

This seems to me like a very specialized use-case that is probably outside the scope of the specification. However, others may certainly have different ideas!

@Youssef1313
Copy link
Author

would the multiline properties be consumed by editors or other tools?

would the multiline properties be consumed by editors or other tools?

Yes, this will be consumed by the C#/VB compiler (ships in Visual Studio).

The current behavior is that this task generates a broken .editorconfig file.

@chrisjohnson00
Copy link

Here is another use case, I want to enforce 120 character line lengths, but the editor config file itself fails the validation due to one of the keys and values being long, 144 chars:

dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected

@cxw42
Copy link
Member

cxw42 commented Jul 29, 2023

@chrisjohnson00 that looks like noncompliant behaviour. The spec says:

Cores must accept keys and values with lengths up to and including 1024 and 4096 characters respectively.

I suggest opening issues against whatever program is giving you the validation error on the editorconfig file.

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

No branches or pull requests

3 participants