Skip to content

Refactor API #36

@badcel

Description

@badcel

Namespace: WCharT

API:

//Buffer is created manually by user to support max flexibility from ReadOnlySpan
string Buffer.ReadString(ReadOnlySpan<WCharT>)
string Buffer.ReadStringNullTerminated(WCharT*);
void Buffer.Fill(string, Span<WCharT>);
int Buffer.GetSize(string); //some Unicode emojis can be 2 characters long.

[WcharT.String("Test")] //Generates code, separate DLL?
ReadOnlySpan<WCharT> WcharT.Strings.Test //Generated property

...
  • Use a source generator to create a static class which contains properties for different wchart strings. Define which properties should be there via an attribute on assembly level. Should be done later as source generators does not support dynamic string generation which is probably most often needed.
  • If an attribute is on class level the strings could be generated inside the class as static property to allow the user to avoid global string collections
  • Add a benchmark to verify the difference between attribute usage or regular usage of a string.
  • Check if it is possible to avoid allocations.
  • Check if it is possible to use stackalloc
  • Consider new type WCharT analog CULong.
  • Check how LibraryImport is doing string marshalling especially in regard to length determination. (It uses a source generator so it is easy to look at the code).
  • Check if there must be any conversion for windows as string is Unicode but probably misses the null termination
  • Does it make sense to use a string builder if a WCharT* is read to avoid getting the length before actual conversion? A loop could read char by char.
  • Check how emojis with multiple characters are handled

API ideas:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions