Looks like we just copy the partial modifier from user code when we shouldn't
Code:
[GeneratedComInterface][InterfaceType(ComInterfaceType.InterfaceIsIUnknown)][Guid(IID)]internalpartialinterfaceICalculator{intAdd(inta,intb);publicpartialintSubtract(inta,intb)=>0;publicpartialintSubtract(inta,intb);publicconststringIID="c67121c6-cf26-431f-adc7-d12fe2448841";}generated:
// <auto-generated />
#pragma warning disable CS0612,CS0618fileunsafeclassInterfaceInformation:global::System.Runtime.InteropServices.Marshalling.IIUnknownInterfaceType{publicstaticglobal::System.GuidIid{get;}=new(newglobal::System.ReadOnlySpan<byte>(newbyte[]{198,33,113,198,38,207,31,67,173,199,209,47,226,68,136,65}));privatestaticvoid**_vtable;publicstaticvoid**ManagedVirtualMethodTable=>_vtable!=null?_vtable:(_vtable=InterfaceImplementation.CreateManagedVirtualFunctionTable());}[global::System.Runtime.InteropServices.DynamicInterfaceCastableImplementationAttribute]fileunsafepartialinterfaceInterfaceImplementation:global::Tutorial.ICalculator{[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.ComInterfaceGenerator","8.0.8.41904")][global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]intglobal::Tutorial.ICalculator.Add(inta,intb){var(__this,__vtable_native)=((global::System.Runtime.InteropServices.Marshalling.IUnmanagedVirtualMethodTableProvider)this).GetVirtualMethodTableInfoForKey(typeof(global::Tutorial.ICalculator));int__retVal;int__invokeRetVal;{__invokeRetVal=((delegate* unmanaged[MemberFunction]<void*,int,int,int*,int>)__vtable_native[3])(__this,a,b,&__retVal);}// NotifyForSuccessfulInvoke - Keep alive any managed objects that need to stay alive across the call.global::System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(__invokeRetVal);global::System.GC.KeepAlive(this);return__retVal;}[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.ComInterfaceGenerator","8.0.8.41904")][global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]partialintglobal::Tutorial.ICalculator.Subtract(inta,intb){var(__this,__vtable_native)=((global::System.Runtime.InteropServices.Marshalling.IUnmanagedVirtualMethodTableProvider)this).GetVirtualMethodTableInfoForKey(typeof(global::Tutorial.ICalculator));int__retVal;int__invokeRetVal;{__invokeRetVal=((delegate* unmanaged[MemberFunction]<void*,int,int,int*,int>)__vtable_native[4])(__this,a,b,&__retVal);}// NotifyForSuccessfulInvoke - Keep alive any managed objects that need to stay alive across the call.global::System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(__invokeRetVal);global::System.GC.KeepAlive(this);return__retVal;}}fileunsafepartialinterfaceInterfaceImplementation{[global::System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute(CallConvs=new[]{typeof(global::System.Runtime.CompilerServices.CallConvMemberFunction)})]internalstaticintABI_Add(global::System.Runtime.InteropServices.ComWrappers.ComInterfaceDispatch*__this_native,inta,intb,int*__invokeRetValUnmanaged__param){global::Tutorial.ICalculator@this=default;refint__invokeRetValUnmanaged=ref*__invokeRetValUnmanaged__param;int__invokeRetVal=default;int__retVal=default;try{// Unmarshal - Convert native data to managed data.@this=global::System.Runtime.InteropServices.ComWrappers.ComInterfaceDispatch.GetInstance<global::Tutorial.ICalculator>(__this_native);__invokeRetVal=@this.Add(a,b);// NotifyForSuccessfulInvoke - Keep alive any managed objects that need to stay alive across the call.__retVal=0;// S_OK// Marshal - Convert managed data to native data.__invokeRetValUnmanaged=__invokeRetVal;}catch(global::System.Exception__exception){__retVal=global::System.Runtime.InteropServices.Marshalling.ExceptionAsHResultMarshaller<int>.ConvertToUnmanaged(__exception);}return__retVal;}[global::System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute(CallConvs=new[]{typeof(global::System.Runtime.CompilerServices.CallConvMemberFunction)})]internalstaticintABI_Subtract(global::System.Runtime.InteropServices.ComWrappers.ComInterfaceDispatch*__this_native,inta,intb,int*__invokeRetValUnmanaged__param){global::Tutorial.ICalculator@this=default;refint__invokeRetValUnmanaged=ref*__invokeRetValUnmanaged__param;int__invokeRetVal=default;int__retVal=default;try{// Unmarshal - Convert native data to managed data.@this=global::System.Runtime.InteropServices.ComWrappers.ComInterfaceDispatch.GetInstance<global::Tutorial.ICalculator>(__this_native);__invokeRetVal=@this.Subtract(a,b);// NotifyForSuccessfulInvoke - Keep alive any managed objects that need to stay alive across the call.__retVal=0;// S_OK// Marshal - Convert managed data to native data.__invokeRetValUnmanaged=__invokeRetVal;}catch(global::System.Exception__exception){__retVal=global::System.Runtime.InteropServices.Marshalling.ExceptionAsHResultMarshaller<int>.ConvertToUnmanaged(__exception);}return__retVal;}}fileunsafepartialinterfaceInterfaceImplementation{internalstaticvoid**CreateManagedVirtualFunctionTable(){void**vtable=(void**)global::System.Runtime.CompilerServices.RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(global::Tutorial.ICalculator),sizeof(void*)*5);{nintv0,v1,v2;global::System.Runtime.InteropServices.ComWrappers.GetIUnknownImpl(outv0,outv1,outv2);vtable[0]=(void*)v0;vtable[1]=(void*)v1;vtable[2]=(void*)v2;}{vtable[3]=(void*)(delegate* unmanaged[MemberFunction]<global::System.Runtime.InteropServices.ComWrappers.ComInterfaceDispatch*,int,int,int*,int>)&ABI_Add;vtable[4]=(void*)(delegate* unmanaged[MemberFunction]<global::System.Runtime.InteropServices.ComWrappers.ComInterfaceDispatch*,int,int,int*,int>)&ABI_Subtract;}returnvtable;}}namespaceTutorial{[global::System.Runtime.InteropServices.Marshalling.IUnknownDerivedAttribute<InterfaceInformation,InterfaceImplementation>]internalpartialinterfaceICalculator{}}namespaceTutorial{internalpartialinterfaceICalculator{}}Error:
Microsoft.Interop.ComInterfaceGenerator\ICalculator.cs(33,46): error CS0759: No defining declaration found for implementing declaration of partial method 'InterfaceImplementation.Subtract(int, int)'
Microsoft.Interop.ComInterfaceGenerator\ICalculator.cs(33,46): error CS0754: A partial method may not explicitly implement an interface method
Microsoft.Interop.ComInterfaceGenerator\ICalculator.cs(33,46): error CS0539: 'InterfaceImplementation.Subtract(int, int)' in explicit interface declaration is not found among members of the interface that can be implemented
Microsoft.Interop.ComInterfaceGenerator\ICalculator.cs(33,46): error CS8796: Partial method 'InterfaceImplementation.Subtract(int, int)' must have accessibility modifiers because it has a non-void return type.
Looks like we just copy the partial modifier from user code when we shouldn't
Code:
generated:
Error: