Skip to content

Fix not showing correct header info, issue #34#312

Merged
nemec merged 2 commits intocommandlineparser:developfrom
tynar:master
Aug 7, 2018
Merged

Fix not showing correct header info, issue #34#312
nemec merged 2 commits intocommandlineparser:developfrom
tynar:master

Conversation

@tynar
Copy link
Copy Markdown
Contributor

@tynar tynar commented Aug 2, 2018

Added preprocessor for .NET Standard and .NET Framework to fix HeadingInfo issue #34 .

…mework it's from AssemblyInfo, for .NET Standard file without extension.
@nemec
Copy link
Copy Markdown
Contributor

nemec commented Aug 2, 2018

I'm beginning to think a better solution may be to simply remove .dll from the end of the title if it exists. It won't require adding new preprocessors and will only affect those who intentionally end their title with .dll, for whatever reason, instead of all of NETSTANDARD.

@tynar I don't see a preprocessor for .NET Framework that calls Path.GetFileNameWithoutExtension, it would hit your #else and simply not trim. Since that trim call was added back in 2013, before Core even existed, .NET Framework users should get the behavior that trims .dll off the end as well as netstandard1_5.

Could you rewrite your change to remove just the string .dll from the end of the title, if it exists? If it passes the tests after that, we should be good to go.

@tynar
Copy link
Copy Markdown
Contributor Author

tynar commented Aug 2, 2018

Wasn't the intention to show the title from AssemblyInfo rather than looking for executed file name? That's why I left else part with title info which is available in .NET Framework.

@nemec
Copy link
Copy Markdown
Contributor

nemec commented Aug 3, 2018

Yes. Note that the existing code calls GetFileNameWithoutExtension on the title attribute, NOT the assembly name. I believe it's meant to solve a problem where, by default, the title attribute is given a name of something.dll if you did not manually set it yourself.

I think if you take the current published code and then replace

GetFileNameWithoutExtension(titleAttribute.Title)

with the following pseudocode (sorry I don't have the time to format it properly)

title = titleAttribute.Title
if title endswith ".dll"
    title = title.Substring(0, title.Length - ".dll".Length)

It should solve the original issue while keeping the spirit of the old behavior.

@nemec nemec changed the base branch from master to develop August 7, 2018 03:05
@nemec nemec merged commit f99cb9e into commandlineparser:develop Aug 7, 2018
@nemec
Copy link
Copy Markdown
Contributor

nemec commented Aug 7, 2018

That looks good to me @tynar, thank you for your contribution to the project!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants