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

SuppressNullableWarningExpression should break consistently with invocation expressions #598

Merged
merged 8 commits into from
Feb 28, 2022

Conversation

belav
Copy link
Owner

@belav belav commented Feb 7, 2022

closes #596

@belav belav marked this pull request as draft February 7, 2022 22:38
@belav
Copy link
Owner Author

belav commented Feb 7, 2022

Some edge cases from https://github.com/belav/csharpier-repos/pull/30/files

                    NamingStrategy namingStrategy = JsonTypeReflector.GetContainerNamingStrategy(
                        attribute
                    )!;
// is now
                NamingStrategy namingStrategy = JsonTypeReflector
                    .GetContainerNamingStrategy(containerAttribute)
                    !;
// probably should be
                NamingStrategy namingStrategy = JsonTypeReflector
                    .GetContainerNamingStrategy(containerAttribute)!;

            IsUnion = JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall<object?>(
                isUnionMethodInfo
            )!;
// is now
            IsUnion = JsonTypeReflector.ReflectionDelegateFactory
                .CreateMethodCall<object?>(isUnionMethodInfo)
                !;

            MethodCall<object?, object> invoke =
                JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall<object?>(invokeFunc)!;
// is now
            MethodCall<object?, object> invoke = JsonTypeReflector.ReflectionDelegateFactory
                .CreateMethodCall<object?>(invokeFunc)
                !;

    private static readonly MethodInfo CallPropertySetterOpenGenericMethod =
        typeof(PropertySetter).GetMethod(
            nameof(CallPropertySetter),
            BindingFlags.NonPublic | BindingFlags.Static
        )!;
// is now
    private static readonly MethodInfo CallPropertySetterOpenGenericMethod = typeof(PropertySetter)
        .GetMethod(nameof(CallPropertySetter), BindingFlags.NonPublic | BindingFlags.Static)
        !;


        var deserialized =
            (JSInProcessObjectReference)JsonSerializer.Deserialize<IJSInProcessObjectReference>(
                json,
                JsonSerializerOptions
            )!;
// is now
        var deserialized = (JSInProcessObjectReference)JsonSerializer
            .Deserialize<IJSInProcessObjectReference>(json, JsonSerializerOptions)
            !;

// is it weird if we do something like?
        _uiThreadId = (int)_window
            .GetType()
            .GetField("_managedThreadId", BindingFlags.NonPublic | BindingFlags.Instance)
            !.GetValue(_window)!;

@belav belav marked this pull request as ready for review February 27, 2022 21:25
Copy link
Collaborator

@shocklateboy92 shocklateboy92 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmmm. You know, when I first skimmed through the .cst files everything looked "fine".
We've probably been overthinking this. The vast majority of people won't look at this in detail and accept whatever we output without question.

@shocklateboy92 shocklateboy92 merged commit 045cea7 into master Feb 28, 2022
@shocklateboy92 shocklateboy92 deleted the null-suppress branch February 28, 2022 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SuppressNullableWarningExpression ( !. ) does not break consistenly
2 participants