Preserve whitespace in nuget description

May 21, 2011 at 11:03 PM

I have nugets that use (to make more readable short snippets of code) but still the library reference dialog removes my newlines, and so does the web gallery.

Should I file this as a bug?

May 21, 2011 at 11:14 PM

What you suggest here is actually the old behavior before 1.3. But in 1.3, I fixed a bug which asks for trimming the description field, because we don't want people enter arbitrary whitespaces, which can make it look quite ugly.

May 22, 2011 at 4:26 AM

I don't quite follow the reasoning.

Have you seen how code snippets look like in the description with the new behavior?

So the feature is gone because someone might use it to make his nuget look ugly instead of much better? :|

May 22, 2011 at 4:33 AM

Unfortunately yes. But why do you want to provide code snippets in the description? I'd argue that it's not the best place to show code snippet.

May 22, 2011 at 8:27 AM

When you have nugets of the granularity of (say) NETFx (i.e. extension methods), it's the perfect place.

http://netfx.codeplex.com/

As a general principle, I don't think products should (totally) prevent conscious users from doing useful things for the sake of making it impossible for careless users to shoot themselves in the foot. 

Maybe a trade-off would be for you to actually check for the existence of xml:space="preserve" meaning I've been very careful and explicit that I do NOT want trimming?

May 22, 2011 at 3:20 PM

Adding xml:space="preserve" is a interesting idea, but it would require adding a property to our IPackageMetadata interface, which I don't think worth it. 

As a work around, you can add a sample.txt file in your package to include your snippet. It requires a bit extra work, but you can add as much code as you like in there.

May 22, 2011 at 4:22 PM

And how would that txt end up in the library reference dialog or the nuget.org site?

From the point of view of the author, your XML processing is broken. It's really not important where you put the flag in the internals, but I believe firmly that you should not break the expectations from the XML standard when authoring the manifest file. That's the whole reason you chose XML in the first place, right? 'cause everyone knows what to expect from it?

Who ever sees IPackageMetadata??

May 22, 2011 at 5:35 PM

Just throwing in my 1 penny, but I agree with kzu. Was this feature added because we were seeing it, or because we thought we would see it?

____
Rob
"Be passionate in all you do"

http://devlicio.us/blogs/rob_reynolds
http://ferventcoder.com
http://twitter.com/ferventcoder

May 22, 2011 at 6:09 PM

What was the bug that caused us to make that change in the first place? It'd be interesting to go back a see what exactly looked bad. On the surface, it does seem wrong to remove spacing that the author chose to include.

May 22, 2011 at 6:28 PM

http://nuget.codeplex.com/workitem/643

I still don't think the Add package dialog is the right place to show snippet.

May 22, 2011 at 6:48 PM

Someone had suggested using markdown in the description awhile back and have each client (including web) format it appropriately.

I still really like that idea.
____
Rob
"Be passionate in all you do"

http://devlicio.us/blogs/rob_reynolds
http://ferventcoder.com
http://twitter.com/ferventcoder

May 22, 2011 at 7:28 PM

@dotnetjunkey: that might be your view of that, yes. I'm telling you that for some very finer-grained nugets, that's the best place to get the point across.

Example: http://nuget.org/List/Packages/netfx-System.StringFormatWith

 

Formats strings with named parameters with a given object, like "Hello {FirstName} {LastName}". 

 

VS:

 

Formats strings with named parameters with a given object, like:


var format = "Hello {FirstName} {LastName}";
var customer = new Customer { FirstName = "Daniel", LastName = "Cazzulino" };
var message = format.FormatWith(customer);
// message = "Hello Daniel Cazzulino"

with the current behavior, this is how that would look like:

Formats strings with named parameters with a given object, like: var format = "Hello {FirstName} {LastName}"; var customer = new Customer { FirstName = "Daniel", LastName = "Cazzulino" }; var message = format.FormatWith(customer);// message = "Hello Daniel Cazzulino"

Guess which one conveys easier what the extension does.

 

@ferventcoder: I'm all for that, but at the bare minimum, xml:space="preserve" should be honored anyways.

May 22, 2011 at 7:37 PM

The details pane on the Add Package dialog is rather thin. It's not ideal to show code snippet there. With your sample code above, each line would wrap, so it will look bad anyway.

Maybe we can honor the whitespace on nuget.org, but not in the dialog, IMO.

Anyway, feel free to open a bug (or reactivate #643 above). We'll triage it accordingly.

May 23, 2011 at 6:08 AM
Edited May 23, 2011 at 6:27 AM

Here's another guy doing the same thing: http://nuget.org/List/Packages/guard_claws/0.0.8 (to me, it's apparent he didn't put a couple more samples as it would look like crap without newlines)

I can manually wrap to ensure it looks good. In fact I used to do it when it worked.

I don't see how I can reactivate a closed issue :(