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

Added ${aspnet-request-form} #313

Merged
merged 9 commits into from
Sep 22, 2018
Merged

Added ${aspnet-request-form} #313

merged 9 commits into from
Sep 22, 2018

Conversation

DrewBrasher
Copy link
Contributor

No description provided.

@codecov
Copy link

codecov bot commented Sep 7, 2018

Codecov Report

Merging #313 into master will increase coverage by 1%.
The diff coverage is 84%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #313   +/-   ##
=====================================
+ Coverage      61%    62%   +1%     
=====================================
  Files          31     32    +1     
  Lines         435    454   +19     
  Branches       92     97    +5     
=====================================
+ Hits          266    282   +16     
- Misses        134    135    +1     
- Partials       35     37    +2
Impacted Files Coverage Δ
...LayoutRenderers/AspNetRequestFormLayoutRenderer.cs 84% <84%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9d95873...a842581. Read the comment docs.

Copy link
Member

@304NotModified 304NotModified left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Looks very good, added some notes for the final touches.

/// Gets or sets the form keys to exclude in the output. If omitted, none are excluded.
/// </summary>
/// <docgen category='Rendering Options' order='10' />
public string Exclude { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem, Set please :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I'm not sure what you are asking for on this one.

Copy link
Member

@304NotModified 304NotModified Sep 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the ordering of the comments are changed. I meant: the same as #313 (comment)

{
formDataList.Add($"{item.Key}={item.Value}");
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice if we could reduce the code duplication here, (foreach / if check)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed code duplication by changing to a foreach that works for both AspNetCore and .net framework. https://github.com/DrewBrasher/NLog.Web/commit/8b7999a93bc75e3834e21d5cd999824bea184976

/// Gets or sets the form keys to include in the output. If omitted, all are included.
/// </summary>
/// <docgen category='Rendering Options' order='10' />
public string Include { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use list/set here :)

(Since NLog 4.4 - https://nlog-project.org/2016/12/14/nlog-4-4-is-live.html)

I prefer a ISet<String> (for .NET 3.5 is should be HashSet<String>)

You could make it default case insensitive.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this?

#if ASP_NET_CORE
        public ISet<string> Include { get; set; }
#else
        public HashSet<string> Include { get; set; }
#endif

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes indeed 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@304NotModified
Copy link
Member

304NotModified commented Sep 10, 2018

nice!

One question, if an item is in include and exclude, which one has precedence? It seems to be exclude, but i'm not sure if that's common. (we need to check that)

@DrewBrasher
Copy link
Contributor Author

You are correct that exclude currently takes precedence. I've looked around and see examples of other software doing it both ways. Either way is fine with me and I will add a unit test to cover whichever way is decided.

Here are some examples:
Include takes precedence
https://docs.citrix.com/en-us/profile-management/current-release/configure/include-and-exclude-items.html

Exclude Takes precedence:
https://docs.microsoft.com/en-us/windows/deployment/usmt/usmt-conflicts-and-precedence

https://stackoverflow.com/questions/11959211/maven-surefire-plugin-include-exclude-precedence

Other examples:
https://gist.github.com/ento/cf5593d4fac3f72d3765b3fe2ed2a204

@DrewBrasher
Copy link
Contributor Author

@304NotModified which one would you rather have take precedence?

@304NotModified 304NotModified self-assigned this Sep 15, 2018
@304NotModified
Copy link
Member

HI,

Thanks for looking at this! I think docs are the most important and as it is inconsistent, I don't prefer really one above the other. So we could keep it like this.

@304NotModified
Copy link
Member

will try to finish this PR in the beginning of next week

Copy link
Member

@304NotModified 304NotModified left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! looks good!

One small improvement is possible, see note

/// Gets or sets the separator to use between each key/value pair. If omitted, <see cref="Environment.NewLine"/> is used.
/// </summary>
/// <docgen category='Rendering Options' order='10' />
public string Separator { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should be a Layout. What do you think? We can use then ${newline} etc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be better. I didn't realize I could do that. Do you think I should still have newline as the default separator or would something else be better as the default? The main reason I had newline as the default was because I didn't know I could set it up to take a layout. Thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think newline is fine, but in other renderers we use space. Not sure what would be the best in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will change it to a space to keep it consistent with the others. With it being a Layout instead of a string people can easily make it a newline if they want.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed the base class AspNetLayoutMultiValueRendererBase and I'm wondering if I should change this to extend that class.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doubting about that. It isn't a bad idea, but unfortunately no Layouts there. Both are fine to me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PS I like to release this soon :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed the layout thing (see #317), so please subclass from
AspNetLayoutMultiValueRendererBase

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I will do that now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@304NotModified 304NotModified changed the title Add aspnet request form layout renderer Added ${aspnet-request-form} Sep 22, 2018
/// Gets or sets the separator to use between each key/value pair. If omitted, <see cref="Environment.NewLine"/> is used.
/// </summary>
/// <docgen category='Rendering Options' order='10' />
public string Separator { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed the layout thing (see #317), so please subclass from
AspNetLayoutMultiValueRendererBase

@304NotModified
Copy link
Member

PS could you see these results?

image

@DrewBrasher
Copy link
Contributor Author

DrewBrasher commented Sep 22, 2018 via email

@304NotModified
Copy link
Member

304NotModified commented Sep 22, 2018

Could you please try again? (added you as Collaborator)

(I think you have an email, with a link you should click first)

@304NotModified
Copy link
Member

anyway for now:

image

@DrewBrasher
Copy link
Contributor Author

I've changed AspNetRequestFormLayoutRenderer to be a subclass of AspNetLayoutMultiValueRendererBase and fixed the code check issue.

@304NotModified
Copy link
Member

🎉 great!

@304NotModified 304NotModified merged commit 21989ad into NLog:master Sep 22, 2018
@304NotModified
Copy link
Member

Could you please help with docs on the wiki and https://github.com/NLog/NLog.github.io/blob/master/config/layout-renderers.json?

I will prepare a release :)

This was referenced Sep 22, 2018
@304NotModified
Copy link
Member

4.7 is live :)

Thanks for the help!

@DrewBrasher
Copy link
Contributor Author

I added aspnet-request-form info to config/layout-renderers.json (https://github.com/DrewBrasher/NLog.github.io/commit/1aab227888d90d29644b6f42f9de76eaa4cd3f1d). What all has to be done to add to the documentation?

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

Successfully merging this pull request may close these issues.

3 participants