Fixed warning SA1119 for Umbraco.Web.UI project#15020
Fixed warning SA1119 for Umbraco.Web.UI project#15020emmagarland wants to merge 1 commit intoumbraco:contribfrom
Conversation
|
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:
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 🤖 🙂 |
|
Not a template expert here, but aren't those parenthesis required by the pre-processor? |
|
@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 - 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 |
|
Interesting - I was going from
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives?redirectedfrom=MSDN#conditional-compilation,
so perhaps it’s more of a personal preference thing?
To be honest, in the rest of my code I’m normally more comfortable using
brackets around if statements anyway, to avoid accidental logical leaks etc…
I agree not to just follow every StyleCop suggestion without checking, and
some might need a pragma instead. But there are lots of other warnings to
tackle too; it’s just that this one was the only one stopping the project
building with no warnings :)
…On Sun, 22 Oct 2023 at 22:12, Mike Bundy ***@***.***> wrote:
@emmagarland <https://github.com/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
—
Reply to this email directly, view it on GitHub
<#15020 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMSZP6UYPWJOBUP5TI2CH3YAWD4JAVCNFSM6AAAAAA6LB2IRKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZUGIYDAMBVGM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
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:
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. |
|
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 |
|
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 👍👍 |
|
Good stuff, thanks @mikecp! |
|
Just to update, this wasn't pulled across into |


Fixed warning SA1119 for Umbraco.Web.UI project
Fixed StyleCop warning SA1119 (unnecessary parenthesis) for
Umbraco.Web.UIproject, and no warnings show up in that project now.Prerequisites
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:truemeans I cannot access the Umbraco backoffice over http (vs being allowed on https).Question
As an aside, where does this
UseHttpsRedirectcome from in the code? I know it lets us callapp.UseHttpsRedirection();but I can't find a reference to it in the solution.