question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Major Rewrite (v2.x)

See original GitHub issue

I’ve been considering a major rewrite for a while, for many reasons:

  • Current version is too coupled with Dapper, it’s barely reusable
  • Too difficult to customize or modify anything. Bad design decisions, I guess
  • Merging SQL statements is just too ugly and the way we’re doing regex conversion back and forth is not efficient. The idea is that we should use a standard format for the underlying string and only do the conversion (and give names to the numbered args) by the moment that we need to invoke Dapper.
  • net6.0+ support InterpolatedStringHandlers which don’t even require regex parsing

As a first draft, I’ve created this fresh project which is just a FormattableString implementation, but it’s like a StringBuilder since it supports Append, Replace, Insert, etc: https://github.com/Drizin/InterpolatedStrings.

The next major release of DapperQueryBuilder will be based on this new library. (I guess major parts of CommandBuilder will be delegated to this other library).

Feel free to share your feedback.

Issue Analytics

  • State:open
  • Created 3 months ago
  • Comments:15 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
jehhynescommented, Jun 26, 2023

Is there any reason you would want to use the pre-net6 version when using net6? If not, couldn’t you do the following to avoid the strange *6 methods?

    public class InterpolatedStringFactory
    {
#if NET6_0_OR_GREATER
        /// <summary>an
        /// Creates a new InterpolatedStringBuilder using an InterpolatedStringHandler (net6.0+) which can be a little faster than using regex.
        /// </summary>
        public virtual InterpolatedStringBuilder Create(InterpolatedStringAdapter value)
        {
            return value.InterpolatedStringBuilder;
        }

        /// <summary>
        /// Creates a new InterpolatedStringBuilder using an InterpolatedStringHandler (net6.0+) which can be a little faster than using regex.
        /// </summary>
        public virtual InterpolatedStringBuilder Create([InterpolatedStringHandlerArgument("options")] InterpolatedStringAdapter value, InterpolatedStringBuilderOptions options)
        {
            return value.InterpolatedStringBuilder;
        }
#else
        /// <summary>
        /// Creates a new InterpolatedStringBuilder using regular expression for parsing the FormattableString. 
        /// </summary>
        public virtual InterpolatedStringBuilder Create(FormattableString source)
        {
            var target = new InterpolatedStringBuilder();
            Parser.ParseAppend(source, target);
            return target;
        }
#endif

Also, you could easily support all the way back to netstandard1.4 (and thus support the .NET Framework back to 4.6.1). To do this:

  1. You have an unneeded using statement to remove in InterpolatedStringParser: using static System.Net.WebRequestMethods;
  2. And make the following change in InterpolatedStringArgumentComparer
        public int GetHashCode(
#if NETCOREAPP
            [DisallowNull] 
#endif
        InterpolatedStringArgument obj)
1reaction
terryaneycommented, Jun 26, 2023

Love re-writes when it cleans up/removes code and makes it more correct! 😃 Couple of easy’ish questions

  1. Is the idea then to re-write DapperQueryBuilder, just leveraging InterpolatedStrings? (either by you or contributors)
  2. In InterpolatedStrings, as someone with zero multi framework support experience, how come the *6 methods are required? That can’t just be detected automatically inside the method and use the appropriate language feature? Surprised me when I saw that, but I’m sure I’m about to be educated 😉
Read more comments on GitHub >

github_iconTop Results From Across the Web

Migrate from version 1.x to 2.x of the AWS SDK for Java
x is a major rewrite of the 1.x code base built on top of Java 8+. It includes many updates, such as improved...
Read more >
Vs. Rewrite (Sonic.exe) - Funkipedia Mods Wiki - Fandom
Lord X is the main antagonist of OTH305's Sonic (PC Port), a game that reimagines the original version of Sonic.EXE. He makes an...
Read more >
FNF VS Rewrite Sonic.EXE | Friday Night Funkin'
FNF VS Rewrite Sonic.EXE is yet another Friday Night Funkin' mod based on the Sonic.EXE creepypasta. Deal with it. Made by Springless (Artist,...
Read more >
What is v2.x equiv of v1's "rewrite" feature? · Issue #2330
I depended on "rewrite" heavily for rewriting PRs before submission. Where the primary task is moving multiple hunks between multiple commits. I'm aware...
Read more >
FNF Vs Rewrite (Sonic.exe)
FNF Vs Rewrite (Sonic EXE) is a rhythm game and Friday Night Funkin mod with a new SonicEXE character. Start playing online! No...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found