Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Implement System.ComponentModel.VersionConverter #28516

Merged
merged 6 commits into from
Aug 17, 2018

Conversation

0xced
Copy link
Contributor

@0xced 0xced commented Mar 27, 2018

VersionConverter is a new System.ComponentModel.TypeConverter subclass that handle conversions between string and System.Version.

Edit @stephentoub 6/12/2018: https://github.com/dotnet/corefx/issues/28594

@0xced 0xced changed the title Implement System.ComponentModel.VersionTypeConverter Implement System.ComponentModel.VersionConverter Mar 27, 2018
@0xced 0xced force-pushed the VersionTypeConverter branch 2 times, most recently from 9d7ebd0 to 834a055 Compare March 27, 2018 19:52
@karelz karelz added area-System.ComponentModel * NO MERGE * The PR is not ready for merge yet (see discussion for detailed reasons) blocked Issue/PR is blocked on something - see comments labels Mar 28, 2018
@karelz
Copy link
Member

karelz commented Mar 28, 2018

@0xced thanks for your PR. You are adding new public API, which needs to go through API review first.
Can you please file an issue with API description, motivation, etc. and work with area owners (@maryamariyan @safern) to agree on that first? Thanks!

@karelz karelz changed the title Implement System.ComponentModel.VersionConverter [NO MERGE] Implement System.ComponentModel.VersionConverter Mar 28, 2018
@safern safern added this to the Future milestone Mar 28, 2018
@stephentoub stephentoub modified the milestones: Future, 2.2.0 Apr 11, 2018
@0xced
Copy link
Contributor Author

0xced commented Apr 21, 2018

I just rebased on master and I see that some tests are still failing.

  • On NETFX x86 Release Build, UWP CoreCLR x64 Debug Build and UWP NETNative x86 Release Build:
    The builds fail with this error, I don't understand why.
VersionConverterTests.cs(11,24): error CS0246: The type or namespace name 'VersionConverter' could not be found (are you missing a using directive or an assembly reference?) [D:\j\workspace\windows-TGrou---2a8f9c29\src\System.ComponentModel.TypeConverter\tests\System.ComponentModel.TypeConverter.Tests.csproj]
  • On Linux x64 Release Build and OSX x64 Debug Build:
    The builds succeed but some tests are failing in System.Net.HttpListener.Tests and System.Net.NameResolution.Functional.Tests which seem totally unrelated to this pull request.

  • On my machine (macOS 10.12.6) I get this error when I try to build the System.ComponentModel.TypeConverter project (It worked fine around 350 commits ago, before I rebased on master today):

$ ./build.sh src/System.ComponentModel.TypeConverter
Tools are already initialized
Running: ~/Projects/corefx/Tools/msbuild.sh /nologo /verbosity:minimal /clp:Summary /maxcpucount /l:BinClashLogger,Tools/Microsoft.DotNet.Build.Tasks.dll;LogFile=binclash.log /p:ConfigurationGroup=Debug  /flp:v=normal  /flp2:warningsonly;logfile=msbuild.wrn  /flp3:errorsonly;logfile=msbuild.err  src/dirs.proj /p:DirectoryToBuild=~/Projects/corefx/src/System.ComponentModel.TypeConverter 
  System.Runtime -> ~/Projects/corefx/bin/ref/System.Runtime/4.2.1.0/netcoreapp/System.Runtime.dll
~/Projects/corefx/Tools/FrameworkTargeting.targets(346,5): error MSB4018: The "FindBestConfigurations" task failed unexpectedly. [~/Projects/corefx/src/System.Runtime/ref/System.Runtime.csproj]
~/Projects/corefx/Tools/FrameworkTargeting.targets(346,5): error MSB4018: System.ArgumentException: No value was provided for property 'TargetGroup' and no default value exists [~/Projects/corefx/src/System.Runtime/ref/System.Runtime.csproj]
~/Projects/corefx/Tools/FrameworkTargeting.targets(346,5): error MSB4018:    at Microsoft.DotNet.Build.Tasks.ConfigurationFactory.ParseConfiguration(String configurationString, Boolean permitUnknownValues) [~/Projects/corefx/src/System.Runtime/ref/System.Runtime.csproj]
~/Projects/corefx/Tools/FrameworkTargeting.targets(346,5): error MSB4018:    at Microsoft.DotNet.Build.Tasks.FindBestConfigurations.Execute() [~/Projects/corefx/src/System.Runtime/ref/System.Runtime.csproj]
~/Projects/corefx/Tools/FrameworkTargeting.targets(346,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() in E:\A\_work\45\s\src\Build\BackEnd\TaskExecutionHost\TaskExecutionHost.cs:line 631 [~/Projects/corefx/src/System.Runtime/ref/System.Runtime.csproj]
~/Projects/corefx/Tools/FrameworkTargeting.targets(346,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__25.MoveNext() in E:\A\_work\45\s\src\Build\BackEnd\Components\RequestBuilder\TaskBuilder.cs:line 787 [~/Projects/corefx/src/System.Runtime/ref/System.Runtime.csproj]

Build FAILED.

I’m a bit lost here, I’m not sure what I should do to fix these issues.

@danmoseley
Copy link
Member

@karelz @wfurt for System.Net.HttpListener.Tests and System.Net.NameResolution.Functional.Tests can we move them out of inner loop? We don't want any flaky tests in CI.

@danmoseley
Copy link
Member

For the other issues I would do git clean -fdx then try again.

To be clear though this API needs approval from the API review board. They might not convene for a couple weeks, and might reject it or want changes...

@danmoseley danmoseley removed * NO MERGE * The PR is not ready for merge yet (see discussion for detailed reasons) blocked Issue/PR is blocked on something - see comments labels Jun 16, 2018
@danmoseley
Copy link
Member

@0xced the API was approved, can you make any necessary changes to match the approved shape, and get tests green?

@dotnet-bot test this please

@0xced 0xced force-pushed the VersionTypeConverter branch 3 times, most recently from c49a644 to 2005213 Compare June 19, 2018 20:32
@stephentoub stephentoub changed the title [NO MERGE] Implement System.ComponentModel.VersionConverter Implement System.ComponentModel.VersionConverter Jun 27, 2018
@0xced
Copy link
Contributor Author

0xced commented Jun 28, 2018

I keep rebasing on master but NETFX x86 Release, UWP CoreCLR x64 Debug and UWP NETNative x86 Release keep failing while all other platforms are fine.

Does anybody has an idea what’s happening with those three platforms?

@stephentoub
Copy link
Member

Does anybody has an idea what’s happening with those three platforms?

The new type you've added only exists in .NET Core; it doesn't exist in .NET Framework or UWP. So the tests when built for .NET Framework or UWP are failing to compile. You need to ensure that your new tests are only built when targeting .NET Core, e.g. with a condition in the project file like Condition="'$(TargetGroup)' == 'netcoreapp'".

@0xced
Copy link
Contributor Author

0xced commented Jul 12, 2018

I just rebased on master and 🎉 all the tests are finally green. ✅

Copy link
Member

@safern safern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @0xced

@safern safern added the * NO MERGE * The PR is not ready for merge yet (see discussion for detailed reasons) label Jul 13, 2018
@karelz
Copy link
Member

karelz commented Jul 19, 2018

@safern why did you mark it as NO MERGE?
This is fairly old PR, how can we push it forward?

@safern
Copy link
Member

safern commented Jul 19, 2018

I added NO MERGE because I'm waiting for response on my comment above: #28516 (comment)

@danmoseley
Copy link
Member

@0xced could you respond to @safern feedback? seem that is all that is left.

@0xced
Copy link
Contributor Author

0xced commented Jul 24, 2018 via email

@danmoseley
Copy link
Member

@0xced sure no problem. I'll let this PR sit then.

@karelz
Copy link
Member

karelz commented Aug 15, 2018

@0xced any update? If you can't work on it now, let's close it and reopen when you have time again. Thanks!

Copy link
Member

@safern safern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@safern safern merged commit a5c7e72 into dotnet:master Aug 17, 2018
@safern
Copy link
Member

safern commented Aug 17, 2018

Thanks @0xced

@0xced 0xced deleted the VersionTypeConverter branch August 18, 2018 07:42
@0xced
Copy link
Contributor Author

0xced commented Dec 4, 2018

Do you know when it will land in .NET Core? I just checked in the recently released version 2.2 and System.ComponentModel.VersionConverter does not exist.

@karelz
Copy link
Member

karelz commented Dec 4, 2018

@0xced it is in 3.0 milestone. Try 3.0 Preview1 - it went out today as well.

@0xced
Copy link
Contributor Author

0xced commented Dec 6, 2018

Excellent! I didn't see it was in a milestone, thanks.

@hughbe
Copy link

hughbe commented Jun 28, 2019

Couple of things that I would like to point out that are inconsistent between UriTypeConverter/VersionConverter and the other type converters in .NET Core:

  • They throw ArgumentNullException for CanConvertFrom(null) whereas .NET Framework returns false. I suggest fixing this to be consistent with other type converters.
  • They return false for CanConvertFrom(typeof(InstanceDescriptor)) because they don't call their base class CanConvertFrom method. See Adhere to desktop implementation of [Can]ConvertFrom #35760. I suggest fixing this
  • They don't support InstanceDescriptor conversion - should this be added to VersionConverter?

@@ -126,6 +126,7 @@ internal ReflectTypeDescriptionProvider()
[typeof(TimeSpan)] = typeof(TimeSpanConverter),
[typeof(Guid)] = typeof(GuidConverter),
[typeof(Uri)] = typeof(UriTypeConverter),
[typeof(Version)] = typeof(VersionConverter),
Copy link

@niemyjski niemyjski Dec 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure would be nice if every type listed here had a comment on the class itself or in docs someplace that stated it had a type converter. The first place I looked when serialization broke for me on the upgrade to 3.1 from 2.2 was on the Version class and I didn't see it. I searched for usages on GitHub and it's parser must have problems with [typeof(Version)] as I searched for typeof(Version) and typeof(System.Version) with no luck. JamesNK/Newtonsoft.Json#2243

picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
* Implement System.ComponentModel.VersionConverter

VersionConverter is a new System.ComponentModel.TypeConverter subclass that handle conversions between string and System.Version.

* Fix tests build for VersionTypeConverter

* Use Version.Parse() instead of new Version() to save an allocation

* Add test data to ensure that the version string is trimmed

* Call base class implementation instead of explicitly throwing

* Always throw a FormatException when a version string is invalid


Commit migrated from dotnet/corefx@a5c7e72
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.ComponentModel * NO MERGE * The PR is not ready for merge yet (see discussion for detailed reasons)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants