Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task: Add ValueStringBuilder as an appendable type to the T4 templates #55

Closed
NightOwl888 opened this issue Nov 17, 2023 · 0 comments · Fixed by #71
Closed

Task: Add ValueStringBuilder as an appendable type to the T4 templates #55

NightOwl888 opened this issue Nov 17, 2023 · 0 comments · Fixed by #71

Comments

@NightOwl888
Copy link
Owner

We will need the ValueStringBuilder overloads to optimize utility methods and avoid heap allocations in the main business logic. This requires updating the CodeGenerationSettings.xml file to include them and editing the T4 templates to correctly generate the overloads.

Note that ValueStringBuilder is a ref struct, so when passed into methods as a parameter, it must be passed as a ref argument. It is also declared internal, so all methods that are generated with it must also be internal.

Example

        public override IAppendable Normalize(string src, IAppendable dest)
        {
            try
            {
                return dest.Append(src);
            }
            catch (IOException e)
            {
                throw new ICUUncheckedIOException(e);  // Avoid declaring "throws IOException".
            }
        }

For the above method, an overload can be generated as:

        internal override void Normalize(string src, ref ValueStringBuilder dest)
        {
            try
            {
                return dest.Append(src);
            }
            catch (IOException e)
            {
                throw new ICUUncheckedIOException(e);  // Avoid declaring "throws IOException".
            }
        }

It would be best to wait until #40 is done before working on this task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant