Skip to content

Conversation

tmilnthorp
Copy link
Collaborator

I was adding some better localization code (via resource files, at least for the prefixes at first), and noticed that if I wanted to use a const for SiPrefixes it would fail during text replacement:

public class SiPrefixes
{
    public const double Milli = 1e-3;
}

x would match the x in SiPrefixes.Milli and the conversion functions (eg GetValueInBaseUnit) would be incorrect:

case AccelerationUnit.MillistandardGravity: return (SiPrefi_valuees.Milli*9.80665) * SiPrefixes.Milli;

A more specific replacement token such as [x] or $x$ would limit scope better since we're doing a string replacement.

Open to ideas for better replacement tokens 😃

@angularsen
Copy link
Owner

angularsen commented Feb 2, 2022

I have no strong preference, but [x] looks like an array to me and $x$ is unfamiliar.

{0} and {myVariable} or {{myVariable}} are commonly used in templating.
How about {value}? Or just {x}.

@tmilnthorp
Copy link
Collaborator Author

I have no strong preference, but [x] looks like an array to me and $x$ is unfamiliar.

{0} and {myVariable} or {{myVariable}} are commonly used in templating. How about {value}? Or just {x}.

That looks good to me.

Is there any doc files I'm missing that need touched?

@codecov
Copy link

codecov bot commented Feb 2, 2022

Codecov Report

Merging #1028 (fd5036f) into master (2ef6659) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #1028   +/-   ##
======================================
  Coverage    82.7%   82.7%           
======================================
  Files         309     309           
  Lines       47598   47598           
======================================
  Hits        39317   39317           
  Misses       8281    8281           

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 2ef6659...fd5036f. Read the comment docs.

@tmilnthorp tmilnthorp changed the title Replacement token Change function token in json files to {x} for better string replace handling Feb 2, 2022
@angularsen
Copy link
Owner

Is there any doc files I'm missing that need touched?

Not that I know of, just search the repo for ... x 😆

@angularsen angularsen changed the title Change function token in json files to {x} for better string replace handling Change replacement token in json files from x to {x} Feb 3, 2022
@angularsen angularsen merged commit 8d2eeb6 into angularsen:master Feb 3, 2022
@angularsen
Copy link
Owner

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