Skip to content

Add IParsable<Uri> implementation to System.Uri - #93479

Closed
KonH wants to merge 1 commit into
dotnet:mainfrom
KonH:feature/uri_iparsable
Closed

KonH wants to merge 1 commit into
dotnet:mainfrom
KonH:feature/uri_iparsable

Conversation

@KonH

@KonH KonH commented Oct 13, 2023

Copy link
Copy Markdown

As described in #92285 new interface implementation added.
I'm not sure how to properly handle nullability in TryParse method, so decided to just create new instance (it looks little bit better than ! usage).
And as I see NoImplicitFilePaths which mentioned in issue is not able to be implemented right now.

@ghost ghost added area-System.Net community-contribution Indicates that the PR has been added by a community member labels Oct 13, 2023
@ghost

ghost commented Oct 13, 2023

Copy link
Copy Markdown

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

As described in #92285 new interface implementation added.
I'm not sure how to properly handle nullability in TryParse method, so decided to just create new instance (it looks little bit better than ! usage).
And as I see NoImplicitFilePaths which mentioned in issue is not able to be implemented right now.

Author: KonH
Assignees: -
Labels:

area-System.Net, community-contribution

Milestone: -

@MihaZupan MihaZupan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for looking to contribute, but in order to implement this API with the behavior described in the API proposal (AllowImplicitFilePaths = false), #59099 will have to be implemented first.

}
}

static bool IParsable<Uri>.TryParse(string? s, IFormatProvider? provider, out Uri result)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The nullability can be handled by adding [MaybeNullWhen(returnValue: false)] to the out Uri result parameter.

The return value should match whether result is null or not.

@ghost ghost added the needs-author-action An issue or pull request that requires more info or actions from the author. label Oct 13, 2023
@KonH

KonH commented Oct 13, 2023

Copy link
Copy Markdown
Author

I see error in CI run:

API breaking changes found. If those are intentional, the APICompat suppression file can be updated by rebuilding with '/p:ApiCompatGenerateSuppressionFile=true'

But when I tried to build with that flag, I got another errors like that:

.../runtime/eng/targetingpacks.targets(125,5): error : The shared framework must be built before the local targeting pack can be consumed. [.../runtime/src/libraries/System.Private.Uri/tests/ExtendedFunctionalTests/System.Private.Uri.ExtendedFunctional.Tests.csproj]

Would be appreciated for links to docs about how to do it.

@ghost ghost removed the needs-author-action An issue or pull request that requires more info or actions from the author. label Oct 13, 2023
@KonH

KonH commented Oct 13, 2023

Copy link
Copy Markdown
Author

Thank you for looking to contribute, but in order to implement this API with the behavior described in the API proposal (AllowImplicitFilePaths = false), #59099 will have to be implemented first.

Got it, I will look at it soon.

@KonH

KonH commented Oct 13, 2023

Copy link
Copy Markdown
Author

Anyway, I'm not sure about actual status of #59099

@MihaZupan

Copy link
Copy Markdown
Member

But when I tried to build with that flag, I got another errors like that:

Did you hit any errors while following the build instructions?
https://github.com/dotnet/runtime/tree/main/docs/workflow/requirements
https://github.com/dotnet/runtime/tree/main/docs/workflow/building/libraries

Anyway, I'm not sure about actual status of #59099

It's currently partially implemented, see #59099 (comment).
The AllowImplicitFilePaths option is one of the things that hasn't been implemented yet.
(note that those changes are more complex than the current PR exposing the IParsable surface area)

@KonH

KonH commented Oct 13, 2023

Copy link
Copy Markdown
Author

Did you hit any errors while following the build instructions?
https://github.com/dotnet/runtime/tree/main/docs/workflow/requirements
https://github.com/dotnet/runtime/tree/main/docs/workflow/building/libraries

I found that this stage is missed:

./build.sh clr+libs -rc Release

Now I run it, but got errors:

Executing ".../Downloads/runtime/src/coreclr/build-runtime.sh" -x64 -release -os linux -pgodatapath ".../.nuget/packages/optimization.linux-x64.pgo.coreclr/1.0.0-prerelease.23507.6" -outputrid linux-x64
  Commencing CoreCLR Repo build
  __OutputRid: linux-x64
  Setting up directories for build
  Checking prerequisites...
  Commencing build of "install" target in "CoreCLR component" for linux.x64.Release in .../Downloads/runtime/artifacts/obj/coreclr/linux.x64.Release
  Invoking ".../Downloads/runtime/eng/native/gen-buildsys.sh" ".../Downloads/runtime/src/coreclr" ".../Downloads/runtime/artifacts/obj/coreclr/linux.x64.Release" x64 linux clang Release ""  -DCLR_CMAKE_PGO_INSTRUMENT=0 -DCLR_CMAKE_OPTDATA_PATH=.../.nuget/packages/optimization.linux-x64.pgo.coreclr/1.0.0-prerelease.23507.6 -DCLR_CMAKE_PGO_OPTIMIZE=1 -DCLI_CMAKE_FALLBACK_OS="linux" -DFEATURE_DISTRO_AGNOSTIC_SSL=1 
  ~/Downloads/runtime/artifacts/obj/coreclr/linux.x64.Release ~/Downloads/runtime/src/coreclr
  Not searching for unused variables given on the command line.
  -- The C compiler identification is Clang 14.0.0
  -- The CXX compiler identification is Clang 14.0.0
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Check for working C compiler: /usr/bin/clang-14 - skipped
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - failed
  -- Check for working CXX compiler: /usr/bin/clang++-14
  -- Check for working CXX compiler: /usr/bin/clang++-14 - broken
  CMake Error at /usr/share/cmake-3.22/Modules/CMakeTestCXXCompiler.cmake:62 (message):
    The C++ compiler
  
      "/usr/bin/clang++-14"
  
    is not able to compile a simple test program.
  
    It fails with the following output:
  -- Configuring incomplete, errors occurred!
  See also ".../Downloads/runtime/artifacts/obj/coreclr/linux.x64.Release/CMakeFiles/CMakeOutput.log".
  See also ".../Downloads/runtime/artifacts/obj/coreclr/linux.x64.Release/CMakeFiles/CMakeError.log".
  
      Change Dir: .../Downloads/runtime/artifacts/obj/coreclr/linux.x64.Release/CMakeFiles/CMakeTmp
      
      Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_e4783/fast && /usr/bin/gmake  -f CMakeFiles/cmTC_e4783.dir/build.make CMakeFiles/cmTC_e4783.dir/build
      gmake[1]: Entering directory '.../Downloads/runtime/artifacts/obj/coreclr/linux.x64.Release/CMakeFiles/CMakeTmp'
      Building CXX object CMakeFiles/cmTC_e4783.dir/testCXXCompiler.cxx.o
      /usr/bin/clang++-14    -MD -MT CMakeFiles/cmTC_e4783.dir/testCXXCompiler.cxx.o -MF CMakeFiles/cmTC_e4783.dir/testCXXCompiler.cxx.o.d -o CMakeFiles/cmTC_e4783.dir/testCXXCompiler.cxx.o -c .../Downloads/runtime/artifacts/obj/coreclr/linux.x64.Release/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
      Linking CXX executable cmTC_e4783
      /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_e4783.dir/link.txt --verbose=1
      /usr/bin/clang++-14 -fuse-ld=lld  CMakeFiles/cmTC_e4783.dir/testCXXCompiler.cxx.o -o cmTC_e4783 
      ld.lld: error: unable to find library -lstdc++
      clang: error: linker command failed with exit code 1 (use -v to see invocation)
      gmake[1]: *** [CMakeFiles/cmTC_e4783.dir/build.make:100: cmTC_e4783] Error 1
      gmake[1]: Leaving directory '.../Downloads/runtime/artifacts/obj/coreclr/linux.x64.Release/CMakeFiles/CMakeTmp'
      gmake: *** [Makefile:127: cmTC_e4783/fast] Error 2
      
      
  
    
  
    CMake will not be able to correctly generate this project.
  Call Stack (most recent call first):
    CMakeLists.txt:4 (project)
  
  
  ~/Downloads/runtime/src/coreclr
  ~/Downloads/runtime/artifacts/obj/coreclr/linux.x64.Release ~/Downloads/runtime/src/coreclr
  Executing make install -j 2
  make: *** No rule to make target 'install'.  Stop.
  ~/Downloads/runtime/src/coreclr
  Failed to build "CoreCLR component".
.../Downloads/runtime/src/coreclr/runtime.proj(95,5): error MSB3073: The command "".../Downloads/runtime/src/coreclr/build-runtime.sh" -x64 -release -os linux -pgodatapath ".../.nuget/packages/optimization.linux-x64.pgo.coreclr/1.0.0-prerelease.23507.6" -outputrid linux-x64" exited with code 2.

Build FAILED.

.../Downloads/runtime/src/coreclr/runtime.proj(95,5): error MSB3073: The command "".../Downloads/runtime/src/coreclr/build-runtime.sh" -x64 -release -os linux -pgodatapath ".../.nuget/packages/optimization.linux-x64.pgo.coreclr/1.0.0-prerelease.23507.6" -outputrid linux-x64" exited with code 2.
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:06:11.31
Build failed with exit code 1. Check errors above.

It's currently partially implemented, see #59099 (comment).
The AllowImplicitFilePaths option is one of the things that hasn't been implemented yet.
(note that those changes are more complex than the current PR exposing the IParsable surface area)

AllowImplicitFilePaths is presented in MihaZupan@fef4435, what is not right with that implementation?

@MihaZupan

Copy link
Copy Markdown
Member

Did you install the Linux prerequisites? https://github.com/dotnet/runtime/blob/main/docs/workflow/requirements/linux-requirements.md

AllowImplicitFilePaths is presented in MihaZupan@fef4435, what is not right with that implementation?

It's been a few years so I don't remember all the details. But at a minimum getting it to build with the current main, and making sure all the edge cases make sense (e.g. combining base/relative addresses with different UriKind and AllowImplicitFilePaths settings).

@hez2010

hez2010 commented Oct 23, 2023

Copy link
Copy Markdown
Contributor

You also need to make changes to the ref assemblies.

@MihaZupan

Copy link
Copy Markdown
Member

Thank you for contributing here. I'll close this PR for now given #93479 (review) -- we'll need to implement #59099 first, so can't make progress here until then

@MihaZupan MihaZupan closed this Oct 23, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Nov 22, 2023
@karelz karelz added this to the 9.0.0 milestone May 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Net community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants