microsoft / CsWinRT

C# language projection for the Windows Runtime
MIT License
542 stars 103 forks source link

Generator crash on non-public interface implementation #936

Closed asklar closed 3 years ago

asklar commented 3 years ago
    public interface MyInterface
    {
        void f(int x, MyEnum myEnum);
    }

    sealed public class MyClass : MyInterface
    {
        public void f(int x, MyEnum myEnum) { }
    }

will crash the generator, it's missing a null check: https://github.com/microsoft/CsWinRT/blob/ad6adcb997b40cea649cf4156451316e714bc3ea/src/Authoring/WinRT.SourceGenerator/WinRTTypeWriter.cs#L912-L913

Should check for null and emit a diagnostic instead

asklar commented 3 years ago

I need to double check what this is again, I'm not sure if it's applicable anymore after my PR to add the diagnostic for "you implemented the interface wrong".

angelazhangmsft commented 3 years ago

@asklar were you able to verify if your PR resolves the issue?

angelazhangmsft commented 3 years ago

Closing the issue, feel free to reopen if it repros