This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 43695 - Nuget resolves .netstandard <= 1.3 when Xamarin.IOS does not support it
Summary: Nuget resolves .netstandard <= 1.3 when Xamarin.IOS does not support it
Status: VERIFIED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: CORLIB (show other bugs)
Version: 4.6.0 (C8)
Hardware: PC Windows
: --- normal
Target Milestone: 4.6.0 (C8)
Assignee: Alexander Köplinger
URL:
Depends on:
Blocks:
 
Reported: 2016-08-24 08:52 UTC by NicolasDorier
Modified: 2016-08-29 12:10 UTC (History)
5 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description NicolasDorier 2016-08-24 08:52:25 UTC
Step to reproduce

* Create new IOS App.
* Add package NBitcoin.
* Add this line: new NBitcoin.Mnemonic(NBitcoin.Wordlist.English, NBitcoin.WordCount.Twelve)

Result:

* Runtime error System.StringNormalizationExtensions.Normalize not implemented.

Expected:

* Nuget should not reference the .NETStandard 1.3 dll of NBitcoin but .NETStandard 1.1
Comment 1 Matt Ward 2016-08-24 09:50:42 UTC
As far as I am aware the NuGet logic is correct since Xamarin.iOS would be mapped to the highest supported .NETStandard assembly available in the NuGet package which for the Bitcoin NuGet package is 1.3. So it looks like the problem is that iOS does not fully implement .NETStandard 1.3.

Xamarin Studio 6.1 uses NuGet 3.4.3 which specifies that Xamarin.iOS supports up to .NETStandard 1.5 so NuGet will pick the highest .NETStandard assembly the NuGet package supplies up to 1.5. In this case NBitcoin has assemblies for .NETStandard 1.1 and 1.3 and NuGet will pick .NETStandard 1.3 since that is supported.

https://github.com/NuGet/NuGet.Client/blob/v3.4.3.855-VSIX-Dev14/src/NuGet.Core/NuGet.Frameworks/DefaultFrameworkMappings.cs#L429-L432

This is similar to how a normal .NET project works. If your project targets .NET 4.5 ,and the NuGet package has assemblies for .NET 2.0, 4.0, then NuGet will pick the highest version that is compatible with your project, which here would be the 4.0 assemblies. NuGet does not pick the lowest target framework version.
Comment 2 NicolasDorier 2016-08-24 10:06:38 UTC
The problem currently is that Nuget says than XamarinIOS support .NETStandard 1.5. While in reality, it is not.
I need to tell my users to unload their project, and change the reference path from 1.3 to 1.6. (https://github.com/MetacoSA/NBitcoin/issues/188) which is very inconvenient, and kill the purpose of NetStandard.

So from now how should I proceed? Is it a nuget problem for mapping to the wrong netstandard version ? or is it a problem of xamarin which somehow does not implement netstandard as specified ?

If you intend to implement netstandard 1.3, do you have any idea around when it will be released?
Comment 3 NicolasDorier 2016-08-24 10:07:18 UTC
I mean chaging reference path from 1.3 to 1.1.
Comment 4 Marek Safar 2016-08-24 10:08:06 UTC
Matt, for C8 we should bump netstandard support up to 1.6
Comment 5 Matt Ward 2016-08-24 10:16:39 UTC
NuGet 3.4.4 currently maps Xamarin.iOS to .NETStandard 1.5.

NuGet 3.5 RC1 maps Xamarin.iOS to .NETStandard 1.7.

So I can modify NuGet 3.4.3 that ships with Xamarin Studio if we need to. If you are using VS 2015 with the latest stable NuGet v3.4.4 then VS and XS would then have different behaviour. Which may or may not be a problem.

Ideally this mapping would not be hard coded inside NuGet.
Comment 6 Alexander Köplinger 2016-08-24 11:00:46 UTC
@Marek, @Matt modifying NuGet to map XI to a different higher NETStandard version will not change the fact that we currently throw NotImplementedException for these string extensions: https://github.com/mono/mono/blob/59260ced5ae1471fac9e50a3c08d3c90a1a3710d/mcs/class/Facades/System.Globalization.Extensions/StringNormalizationExtensions.cs

These look like easy to implement methods (they exist on string already) so we should just add them to C8.
Comment 7 Marek Safar 2016-08-24 11:17:31 UTC
@alexander I know. My concern is to avoid another issue when someone will need 1.6 dependency which we announced as supported but does not appear to work based on Matts comment with C8.
Comment 8 Alexander Köplinger 2016-08-24 12:13:56 UTC
@Marek I see, that's a different issue. Since VS ships with a NuGet that maps XI to netstandard1.5 I'd prefer not modifying the NuGet we ship in XS as that'll just lead to even more confusion. Waiting for NuGet 3.5 might be the better option.

@Nicolas I opened a pull request with a fix for this issue: https://github.com/mono/mono/pull/3444

Thanks for reporting it! I'll post a link to builds for Xamarin.iOS once they're available.
Comment 9 Alexander Köplinger 2016-08-25 11:06:05 UTC
The missing StringNormalizationExtensions.Normalize implementation was fixed in mono master/399de6b18cb29b95ea6f479288b5634e956d89b1 and mono-4.6.0-branch/83897d4af182206f72a30c597093a3a6ed87e04d.

You can find a build of Xamarin.iOS which includes these changes on https://jenkins.mono-project.com/view/Xamarin.MaciOS/job/xamarin-macios-builds-cycle8/

For the more general issue of the netstandard mapping in NuGet I filed https://bugzilla.xamarin.com/show_bug.cgi?id=43742.
Comment 10 Sunil Kumar 2016-08-26 19:29:18 UTC
************************************************************
Reproduce Status:
************************************************************

I have tried to reproduce this issue with Mono 4.6.0.165 + XI 9.99.4.20 using steps mentioned in bug description and getting the same Runtime error System.StringNormalizationExtensions.Normalize not implemented. in Application output and application gets crash as shown in screencast: http://www.screencast.com/t/wqZJSNeZ3Zp

************************************************************
Verify Status:
************************************************************

I have checked this issue with latest C8 Mono 4.6.0.174 + XI 9.99.5.15 and observed that now this issue is working fine. Now application is working fine and not getting Runtime error System.StringNormalizationExtensions.Normalize not implemented. in Application output.

Screencast: http://www.screencast.com/t/rmcn3rU4TC

Environment info:
https://gist.github.com/sunil360/6a81a756cc344dbde297ba6746d6e73f

Hence I am closing this issue.
Comment 11 Sunil Kumar 2016-08-29 12:10:36 UTC
I also checked this issue with latest Master Mono 4.7.0.380_448da87d4498a175da4d2eda233b939012e80f30 + XI 9.11.0.119_db04e2435b36113f11a83b3a6a5ef7e3506103d4 and observed that now this issue is working fine. Now application is working fine and not getting Runtime error 'System.StringNormalizationExtensions.Normalize not implemented.' in Application output. 

Screencast: http://www.screencast.com/t/TCNYeUMX

Environment info: 
https://gist.github.com/sunil360/ca9b4899a2f0355191eba523ada5e8b7

Note You need to log in before you can comment on or make changes to this bug.