Xamarin-android: Default C# 8

Created on 17 Oct 2019  Â·  21Comments  Â·  Source: xamarin/xamarin-android

In VS 2019 16.3/8.3 C# 8 should be the default language version as it is officially supported. @terrajobst @cartermp

I created one in iOS too: https://github.com/xamarin/xamarin-macios/issues/7245

App+Library Build Bindings

Most helpful comment

In case it might also be useful to mention, note that this specific GitHub issue in the xamarin-android repo is only about the Xamarin.Android project type. So for example, if you create a new Mobile App (Xamarin.Forms) app, the .NET Standard library part of that app does not yet default to supporting C# 8.0 language features, but the Xamarin.Android app project part of the app does.

All 21 comments

Our targets need to increase the <MaxSupportedLangVersion> to 8.0 in order to opt-in to C# 8 support by default I believe. We'll work to include this by default.

/cc @jonathanpeppers @jpobst

Release status update

A new Preview version has now been published that includes the fix for this item. The fix is not yet included in a Release version. I will update this item again when a Release version is available that includes the fix.

Fix included in Xamarin.Android 10.1.0.29.

Fix included on Windows in Visual Studio 2019 version 16.4 Preview 3. To try the Preview version that includes the fix, check for the latest updates in Visual Studio Preview.

Fix included on macOS in Visual Studio 2019 for Mac version 8.4 Preview 2. To try the Preview version that includes the fix, check for the latest updates on the Preview updater channel.

Release status update

A new Release version has now been published on Windows that includes the fix for this item. The fix is not yet published in a Release version on macOS. I will update this item again when a Release version is available on macOS that includes the fix.

Fix included in Xamarin.Android 10.1.0.30.

Fix included on Windows in Visual Studio 2019 version 16.4. To get the new version that includes the fix, check for the latest updates or install the latest version from https://visualstudio.microsoft.com/downloads/.

(Fix also included on macOS in Visual Studio 2019 for Mac version 8.4 Preview 2.1 and higher. To try the Preview version that includes the fix, check for the latest updates on the Preview updater channel.)

Using Xamarin.Android 10.2.0.16 and its still complaining about 8.0 (vs2019 16.5.0 preview 1)

I've updated everything possible, and this doesn't work.

I did a file -> new project and it worked just fine for me. in 16.4

This is specifically inside of the Android project. You still need to turn it on manually for .NET standard 2.0: https://montemagno.com/use-csharp-8-everywehre/

i did too @jamesmontemagno ......is there any thing in android .csproj that specify is 8.0 compatible?

So, in the latest 16.4 it should just work from what I tested, however, I didn't test older projects on it.

You can add:

<LangVersion>8.0</LangVersion>

to your csproj and that will light it up :)

add to android .csproj ?

Yup, I put it in all my projects, it is wherever you want to use 8.0 you just put it in there.

thank you

This worked for me as well

Release status update

A new Release version has now been published on macOS that includes the fix for this item for the Xamarin.Android project type, as was published earlier on Windows.

Fix included in Xamarin.Android 10.1.1.0.

Fix included on macOS in Visual Studio 2019 for Mac version 8.4. To get the new version that includes the fix, check for the latest updates on the Stable updater channel.

(Fix also included on Windows in Visual Studio 2019 version 16.4 and higher. To get the new version that includes the fix, check for the latest updates or install the latest version from https://visualstudio.microsoft.com/downloads/.)

This can't be right, as in 16.5 I still had to manually change it on windows visual studio

@EvoPulseGaming Can you be more specific as to what isn't working for you? What type of project, etc?

I just created a new Xamarin Android app from the template in 16.5 P1 and am able to use C# 8 features without changing anything.

What about everyone with an existing project?

On Thu, Jan 9, 2020, 10:26 AM Jonathan Pobst notifications@github.com
wrote:

@EvoPulseGaming https://github.com/EvoPulseGaming Can you be more
specific as to what isn't working for you? What type of project, etc?

I just created a new Xamarin Android app from the template in 16.5 P1 and
am able to use C# 8 features without changing anything.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/xamarin/xamarin-android/issues/3807?email_source=notifications&email_token=AALEEEM4HRMUWZGIIDLFUJLQ45FZXA5CNFSM4JBSVXTKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIQ4JGQ#issuecomment-572638362,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AALEEEIMKGXIKAKM6SJGUZLQ45FZXANCNFSM4JBSVXTA
.

It should be automatic, unless you've set <LangVersion> manually to something else in your project.

In case it might also be useful to mention, note that this specific GitHub issue in the xamarin-android repo is only about the Xamarin.Android project type. So for example, if you create a new Mobile App (Xamarin.Forms) app, the .NET Standard library part of that app does not yet default to supporting C# 8.0 language features, but the Xamarin.Android app project part of the app does.

Ohhh, okay, gotcha. Thanks for the clarification.

On Thu, Jan 9, 2020, 12:31 PM Brendan Zagaeski notifications@github.com
wrote:

In case it might also be useful to mention, note that this specific GitHub
issue in the xamarin-android repo is only about the Xamarin.Android project
type. So for example, if you create a new Mobile App (Xamarin.Forms)
app, the .NET Standard library part of that app does not yet default to
supporting C# 8.0 language features, but the Xamarin.Android app project
part of the app does.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/xamarin/xamarin-android/issues/3807?email_source=notifications&email_token=AALEEENS2SBUHZ4WNXABCYTQ45UPZA5CNFSM4JBSVXTKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIRJM2Q#issuecomment-572692074,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AALEEEJDC7GY333VBBGKR6DQ45UPZANCNFSM4JBSVXTA
.

Visual Studio 16.7.4 and a new Xamarin Android project still requires editing .csproj for some reason. ¯\_(ツ)_/¯
@brendanzagaeski

Roslyn renamed an MSBuild property that broke this in 16.7, see: https://github.com/xamarin/xamarin-android/pull/5054

This fix is in 16.8.

Was this page helpful?
0 / 5 - 0 ratings