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

[Enhancement] Keep Native Platform API with the same name convention as it is in Native Platform #522

Closed
redradist opened this issue Mar 16, 2021 · 4 comments
Labels

Comments

@redradist
Copy link

redradist commented Mar 16, 2021

Summary

I have lots of experience in Xamarin.Forms and Xamarin in general and one of the issues in this framework is that when I copy platform example to .NET project it is not working without renaming the whole API !!

API Changes

I think it would be helpful to have the same API name conversion as in Native Platform or at least to provide the same API in two variants:

// C# naming conversion
var toast = Toast.MakeText(context, text, duration);
toast.Show();

// Android naming conversion
var toast = Toast.makeText(context, text, duration);
toast.show();

As all Native Platform API Bindings generated by external tool, it means that we could generate two functions instead of one:

class Toast
{
  Toast MakeText(...)
  {
    ...
  }
  Toast makeText(...)
  {
    return MakeText(...);
  }
}

There are lots of frameworks that support Native Platform API as it is: NativeScript, Tensorflow.NET, and it seems very useful

Intended Use Case

Intended to be easier to learn platform API

@GalaxiaGuy
Copy link
Contributor

The bindings to the native platform are maintained in https://github.com/xamarin/xamarin-android and https://github.com/xamarin/xamarin-macios for Android and iOS respectively, and so those repose would be the better places to bring this up.

However, I doubt you will get much support as the advantages seem minimal. You say that you have to rename the whole API when copying platform examples - in my experience much more has to change when copying native Android code and just changing case is a small part. This will only increase as more is written in Kotlin.

@redradist
Copy link
Author

redradist commented Mar 17, 2021

The bindings to the native platform are maintained in https://github.com/xamarin/xamarin-android and https://github.com/xamarin/xamarin-macios for Android and iOS respectively, and so those repose would be the better places to bring this up.

However, I doubt you will get much support as the advantages seem minimal. You say that you have to rename the whole API when copying platform examples - in my experience much more has to change when copying native Android code and just changing case is a small part. This will only increase as more is written in Kotlin.

@GalaxiaGuy I agree that it is maintained by separate projects, but only guys that develop MAUI can decide to request this feature for next major framework as MAUI otherwise guys in that project will just reject this request

And regarding the Kotlin, Android documentation provides examples for both Java and Kotlin languages ;)

@hartez hartez changed the title [Enhancement] Keep Native Platform API with the same name convension as it is in Native Platform [Enhancement] Keep Native Platform API with the same name convention as it is in Native Platform Mar 19, 2021
@hartez
Copy link
Contributor

hartez commented Mar 19, 2021

This would be a breaking change for all existing Xamarin.Android and Xamarin.iOS code, and cause a similar problem for anyone porting existing Xamarin.Forms code to MAUI. Plus those names would violate the C# and .NET naming conventions; since MAUI is part of .NET, we need to remain consistent with those naming conventions.

That said, there may be some demand for a Visual Studio extension which can automatically convert pasted Java examples into C# by fixing names and casing. Maybe someone in the community can take a stab at that.

@redradist
Copy link
Author

redradist commented Aug 31, 2021

@hartez

This would be a breaking change for all existing Xamarin.Android and Xamarin.iOS code, and cause a similar problem for anyone porting existing Xamarin.Forms code to MAUI. Plus those names would violate the C# and .NET naming conventions; since MAUI is part of .NET, we need to remain consistent with those naming conventions.

That said, there may be some demand for a Visual Studio extension which can automatically convert pasted Java examples into C# by fixing names and casing. Maybe someone in the community can take a stab at that.

Oh ... Some of Microsoft guys think differently as I mentioned in dotnet/machinelearning#5918
(they will support Python naming convention)

Also I do not ask to break existing code, I ask to generate method with two names ...
Also it can be generate in separate namespace like Microsoft.Maui.Android.Native without breaking of Microsoft.Maui.Android symbols

@ghost ghost locked as resolved and limited conversation to collaborators Feb 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants