Skip to content

Invalid Parse and TryParse parameter when backing type is Guid #43

@wilsonrivera

Description

@wilsonrivera

While trying version 1.6.0 of the package, I found the issue that an extra method is generated for the Parse and TryParse methods when using Guids

The Parse(ReadOnlySpan<byte> ...) and TryParse(ReadOnlySpan<byte> ...) are not defined on the Guid method but for the numeric types

image

The generated code is the following:

#if NET8_0_OR_GREATER
        public static UserId Parse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider)
        {
            return new UserId(System.Guid.Parse(utf8Text, provider));
        }
 
        public static bool TryParse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider, out UserId result)
        {
            if (System.Guid.TryParse(utf8Text, provider, out var r))
            {
                result = new UserId(r);
                return true;
            }
            else
            {
                result = default(UserId);
                return false;
            }
        }
#endif

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions