fsprojects / FSharp.TypeProviders.SDK

The SDK for creating F# type providers
https://fsprojects.github.io/FSharp.TypeProviders.SDK/
MIT License
298 stars 94 forks source link

Fix interface generation and abstract classes #331

Closed thinkbeforecoding closed 4 years ago

thinkbeforecoding commented 4 years ago

This is a fix for interfaces generation for Generative provider. #211

The code instanciated the ILMethodBuilder before checking whether the method is abstract, which does produce an non empty VAR for the method. The TypeAttributes where not automatically correctly set for interfaces. MethodAttributes where not automatically set for interface or abstract classes.

thinkbeforecoding commented 4 years ago

At first, I fix the method attributes just a IL generation... but it caused a problem at design time (the compiler was complaining that the method was sealed !). So I moved the attribute fix inside the ProvidedMethod, and it works.

I also avoid to set Sealed on the type when it's an Interface.

sergey-tihon commented 4 years ago

@thinkbeforecoding can we merge #213 here and ensure that test works now?

thinkbeforecoding commented 4 years ago

Ah yes, that would be neat

thinkbeforecoding commented 4 years ago

I updated the PR with tests from #213

thinkbeforecoding commented 4 years ago

There seem to be some issues with abstract classes. But it shouldn't be difficult to fix

thinkbeforecoding commented 4 years ago

Yes ! It's passing now. I simply force abstract attribute on methods that have no method impl.

panesofglass commented 4 years ago

@thinkbeforecoding, thank you for tackling this! Great work!

thinkbeforecoding commented 4 years ago

Is there anything more to do to get it merged ? 😄

thinkbeforecoding commented 4 years ago

The creation of the interface was working, but there was still some problems with with implementing it on a class with DefineMethodOverride.. Especially:

thinkbeforecoding commented 4 years ago

With this version I have a working from scratch WsdlProvider sdk. It parses the Wsdl using System.Xml.Linq and produces all data types, the interface with System.ServiceModel attributes, and the client class that derives from ClientBase<'t> where 't is the service interface, same way the original WsdlTp does, but here without using svcutil and the C# compiler. It is faster and less hacky.

thinkbeforecoding commented 4 years ago

The WsdlProvider is there: https://github.com/thinkbeforecoding/FSharp.Data.WsdlProvider 😀

dsyme commented 4 years ago

Looks like conflicts need to be resolved here?

thinkbeforecoding commented 4 years ago

This is because #332 already contains all these changes. It should be ok to just close this one