Skip to content

[Bug]: required partial value type property emits code doesn't compile #237

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

Open
chsbuffer opened this issue May 23, 2025 · 0 comments
Open
Labels
bug Something isn't working

Comments

@chsbuffer
Copy link

Describe the bug 🐞

Image

Step to reproduce

namespace MyNamespace
{
    public struct MyStruct;
    
    public partial class Foo : ReactiveObject
    {
        [Reactive(UseRequired = true)] 
        public required partial MyStruct StructProp { get; set; }

        [Reactive(UseRequired = true)] 
        public required partial long LongProp { get; set; }
    }
}

Reproduction repository

No response

Expected behavior

        if (propertyInfo.IncludeMemberNotNullOnSetAccessor || propertyInfo.IsReferenceTypeOrUnconstrainedTypeParameter)
        {
            return
$$"""
        {{fieldSyntax}}
        /// <inheritdoc cref="{{fieldName}}"/>
        {{propertyAttributes}}
        {{propertyInfo.TargetInfo.TargetVisibility}}{{propertyInfo.Inheritance}} {{propertyInfo.UseRequired}}{{partialModifier}}{{propertyInfo.TypeNameWithNullabilityAnnotations}} {{propertyInfo.PropertyName}}
        { 
            get => {{propertyInfo.FieldName}};
            [global::System.Diagnostics.CodeAnalysis.MemberNotNull("{{fieldName}}")]
            {{propertyInfo.AccessModifier}} => this.RaiseAndSetIfChanged(ref {{fieldName}}, value);
        }
""";
        }

        return
$$"""
        {{fieldSyntax}}
        /// <inheritdoc cref="{{fieldName}}"/>
        {{propertyAttributes}}
-        {{propertyInfo.TargetInfo.TargetVisibility}}{{propertyInfo.Inheritance}} {{partialModifier}}{{propertyInfo.UseRequired}}{{propertyInfo.TypeNameWithNullabilityAnnotations}} {{propertyInfo.PropertyName}} { get => {{propertyInfo.FieldName}}; {{propertyInfo.AccessModifier}} => this.RaiseAndSetIfChanged(ref {{fieldName}}, value); }
+        {{propertyInfo.TargetInfo.TargetVisibility}}{{propertyInfo.Inheritance}} {{propertyInfo.UseRequired}}{{partialModifier}}{{propertyInfo.TypeNameWithNullabilityAnnotations}} {{propertyInfo.PropertyName}} { get => {{propertyInfo.FieldName}}; {{propertyInfo.AccessModifier}} => this.RaiseAndSetIfChanged(ref {{fieldName}}, value); }
""";

Screenshots 🖼️

No response

IDE

No response

Operating system

No response

Version

No response

Device

No response

ReactiveUI Version

No response

Additional information ℹ️

No response

@chsbuffer chsbuffer added the bug Something isn't working label May 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant