GithubHelp home page GithubHelp logo

Comments (16)

mrlacey avatar mrlacey commented on May 12, 2024 3

For scenarios like this, where there's an unwritten rule about naming conventions, I like to create a test (or tests) to ensure any future changes follow the rule too.
How do others feel about this?
Such a test would iterate over all XAML files in the project and fail if any of the defined u:Id or x:Name values do not have the correct casing pattern.
Would such a test be appropriate in the 'CalculatorUnitTests' project or should it go somewhere else?

from calculator.

danbelcher-MSFT avatar danbelcher-MSFT commented on May 12, 2024 1

Any and all occurrences of x:Name should use Pascal-case. Right now, it is inconsistent between views. The reasoning is that x:Name converts the object to be accessible as a property of the current view and properties should be Pascal-cased. I think this issue is easily fixed with a regex + replace.

from calculator.

danbelcher-MSFT avatar danbelcher-MSFT commented on May 12, 2024 1

Works on my end:
image
image

from calculator.

danbelcher-MSFT avatar danbelcher-MSFT commented on May 12, 2024 1

@jlaanstra has a good point. It's unfortunate that we wasted Lance's time making that change. @LanceMcCarthy, I apologize for that. We should revert the changes to the resw and focus on only updating the x:Names.

from calculator.

MicrosoftIssueBot avatar MicrosoftIssueBot commented on May 12, 2024

This is your friendly Microsoft Issue Bot. I created this issue automatically as requested by a team member.

from calculator.

LanceMcCarthy avatar LanceMcCarthy commented on May 12, 2024

Can I get clarification on which views are to be updated?

My understanding of the request is the x:Name and x:Uid of XAML-defined UIElement should use Pascal casing:

Ex.

<TextBlock x:Name="firstNameTextBox" />

Should be

<TextBlock x:Name="FirstNameTextBox" />

from calculator.

danbelcher-MSFT avatar danbelcher-MSFT commented on May 12, 2024

x:Uid I am less concerned with, although following the same convention feels appropriate. This would require updating the values in the resw files. Also accomplishable with Replace.

from calculator.

LanceMcCarthy avatar LanceMcCarthy commented on May 12, 2024

Okay, I can take this one

PS - I'm avoiding modifying C++ as much as possible if you couldn't tell already :)

from calculator.

danbelcher-MSFT avatar danbelcher-MSFT commented on May 12, 2024

That's fine, there is a lot of impactful work that can be done in just XAML. I do enjoy discussing C++, however, and I'm happy to recommend learning resources ranging across different levels of experience :)

from calculator.

grochocki avatar grochocki commented on May 12, 2024

IMO, leveraging unit tests to enforce a style/naming convention feels a bit unorthodox. XAML Styler is used to enforce other rules in XAML files in the project; perhaps this is a useful feature for the that tool?

from calculator.

LanceMcCarthy avatar LanceMcCarthy commented on May 12, 2024

FYI - This cannot be solved with a simple regex and replace all. There are a ton of visual state triggers and style setters that will get erroneously overwritten.

It's a case of one at a time Find and Replace, taking care not to accidentally change AutomationIDs and Uids before those tasks are directly approached.

I'm about 1/2 way through the views now.

If you do know of a regex that works in VS2017 for matching: {x:Name"}{[A-Z\s+]}{[a-z0-9]*} to stop at camel-casing names, that would save me a little time, but not much. It's easy to click past x:Name= matches that are properly cased.

from calculator.

danbelcher-MSFT avatar danbelcher-MSFT commented on May 12, 2024

Hey Lance, this regex will find x:Names that are camel-cased: x:Name="[a-z] Or were you looking for something different?

from calculator.

LanceMcCarthy avatar LanceMcCarthy commented on May 12, 2024

That was my first try, but the quotes were messing with the regex-Find, when I removed it, I got no results. I figured it just me messing up the expression.

I'll try it again, but use Resharper for C++.

from calculator.

LanceMcCarthy avatar LanceMcCarthy commented on May 12, 2024

It looks like when we went from private to public, something was broken with my private copy of the repo (it was forked a while before this went public). It removed linked commits, preventing me from opening a Pull Request and automatically unassigned me from this task.

To fix this, I had to re-fork the public repo and copy over my fixes to the latest master branch.

Unfortunately, this means all the work is going to be inside a single commit. However, this also allowed me to manually check for conflicts before pushing the commit.

from calculator.

LanceMcCarthy avatar LanceMcCarthy commented on May 12, 2024

Opened #244

from calculator.

jlaanstra avatar jlaanstra commented on May 12, 2024

Are we sure we want to change all x:Uid keys? How will the loc system handles this?

from calculator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.