Skip to content

Fixed warning SA1119 for Umbraco.Web.UI project#15020

Closed
emmagarland wants to merge 1 commit intoumbraco:contribfrom
emmagarland:hotfix/15015-removewarnings-umbracowebui
Closed

Fixed warning SA1119 for Umbraco.Web.UI project#15020
emmagarland wants to merge 1 commit intoumbraco:contribfrom
emmagarland:hotfix/15015-removewarnings-umbracowebui

Conversation

@emmagarland
Copy link
Copy Markdown
Collaborator

Fixed warning SA1119 for Umbraco.Web.UI project

Fixed StyleCop warning SA1119 (unnecessary parenthesis) for Umbraco.Web.UI project, and no warnings show up in that project now.

Prerequisites

  • I have added steps to test this contribution in the description below

If there's an existing issue for this PR then this fixes: part of my issue #15015

Description

Continuation of removal of warnings per project.

I have tested that setting UseHttps:true means I cannot access the Umbraco backoffice over http (vs being allowed on https).

Question

As an aside, where does this UseHttpsRedirect come from in the code? I know it lets us call app.UseHttpsRedirection(); but I can't find a reference to it in the solution.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Oct 22, 2023

Hi there @emmagarland, thank you for this contribution! 👍

While we wait for one of the Core Collaborators team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:

  • It's clear what problem this is solving, there's a connected issue or a description of what the changes do and how to test them
  • The automated tests all pass (see "Checks" tab on this PR)
  • The level of security for this contribution is the same or improved
  • The level of performance for this contribution is the same or improved
  • Avoids creating breaking changes; note that behavioral changes might also be perceived as breaking
  • If this is a new feature, Umbraco HQ provided guidance on the implementation beforehand
  • 💡 The contribution looks original and the contributor is presumably allowed to share it

Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution.

If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request.

Thanks, from your friendly Umbraco GitHub bot 🤖 🙂

@c9mb
Copy link
Copy Markdown

c9mb commented Oct 22, 2023

Not a template expert here, but aren't those parenthesis required by the pre-processor?
StyleCop is VERY opinionated, so may be worth checking the status before accepting all suggestions.

@emmagarland
Copy link
Copy Markdown
Collaborator Author

@c9mb it's a good question, but I'm pretty sure that since there is only one condition (similarly to DEBUG) it looks like it would work fine (I've double checked the MSDN docs).

On that note though, I have tested the status from changing the appsettings.json to UseHttps and it does still enforce it, but I don't think this is a true test, because (as per my last sentence on the PR) I couldn't find any reference to this symbol anywhere in the solution.

I've looked in the "conditional compilation symbols" on the project properties, and it's not there either.

It is such a key piece of the code, so I do want to double check the way this bit of code was intended to work. Probably safest to put it back in draft for now until I can confirm the before/after behaviour from HQ.

@emmagarland emmagarland marked this pull request as draft October 22, 2023 20:37
@c9mb
Copy link
Copy Markdown

c9mb commented Oct 22, 2023

@emmagarland - the dotnet templating wiki would certainly seem to indicate they are expected for C# but I have no idea if that's a requirement or guidance. https://github.com/dotnet/templating/wiki/Conditional-processing-and-comment-syntax#json-files

@emmagarland
Copy link
Copy Markdown
Collaborator Author

emmagarland commented Oct 22, 2023 via email

@mikecp
Copy link
Copy Markdown
Contributor

mikecp commented Oct 26, 2023

Hi @emmagarland ,

Thanks for your continuous work on reducing the warning count 😅👍

I'll wait for you to finalize your PR before merging it, but regarding your question on where this variable comes from, I investigated a little and found the following:

  • Thanks to the "Blame" method on the file, I could trace the addition of this to the following commit from 2 years ago : 138ef42

  • It is actually linked to the addition of a UseHttpsRedirect parameter in the template.json file of the Umbraco Project

image

  • This parameter comes under the section "symbols" further up in that json file

  • The syntax in the Startup.cs file is that of using Conditional compilation symbols

image

Putting all this together, my best guest for all this to make sense - as I have never created projects from Umbraco Template - is that this is a parameter/setting that you can specify at the moment you create your new project from the Umbraco Template, and that it then creates a conditional compilation symbol into your project if you set that parameter to true/checked state.
But then I might also be completely wrong 😅

@emmagarland
Copy link
Copy Markdown
Collaborator Author

Ah, good find @mikecp!

I will try to replicate this using the templates approach so I can confirm that it still works with my update :)

Thanks

Emma

@mikecp
Copy link
Copy Markdown
Contributor

mikecp commented Nov 2, 2023

Hi @emmagarland , the same issue has been fixed in PR #15110 so I'll close this one for now.

Thanks for initiating this cleanup process by the way 👍👍

@mikecp mikecp closed this Nov 2, 2023
@emmagarland emmagarland deleted the hotfix/15015-removewarnings-umbracowebui branch November 2, 2023 15:17
@emmagarland
Copy link
Copy Markdown
Collaborator Author

Good stuff, thanks @mikecp!

@emmagarland
Copy link
Copy Markdown
Collaborator Author

Just to update, this wasn't pulled across into Program.cs so I've opened a new PR here for that: #16958

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.

5 participants