Code Monkey home page Code Monkey logo

Comments (10)

fluentmoheshwar avatar fluentmoheshwar commented on June 3, 2024 1

image
It works!

from powertype.

AnderssonPeter avatar AnderssonPeter commented on June 3, 2024

Thanks for the issue looks like it doesn't allow ExecutionPolicy.Unrestricted, to be honest I haven't tried this on linux yet so it might not be Arch specific.

from powertype.

AnderssonPeter avatar AnderssonPeter commented on June 3, 2024

@KJP12 could you try 0.0.15 and see if that works as expected?

from powertype.

Ampflower avatar Ampflower commented on June 3, 2024

Enable-PowerType now throws a URI parsing exception. It seems like either .NET Core or PowerShell doesn't return the location information, given the following:

> [System.Reflection.Assembly]::GetExecutingAssembly()

GAC    Version        Location
---    -------        --------
False  v4.0.30319     

Location however might be just blank here because it is being interpreted. Although, it's possible that it is getting something for a URI anyways, given that /home/name and @ both being passed into the URI builder return the same error without giving any useful information, which seems like a rather odd choice of .NET for being able to debug it, since it removes any ability to even know why. It does seem that C:/home/name does however get correctly converted to the file protocol with it returning file:///C:/home/name. It might be more ideal to go ahead and process the path through a URL escaper then prepending file:/// before it before throwing it at URI? That would also account for #, ? and % being present, even if it isn't normally allowed by Windows. Alternatively, if there is a builder API of sorts, that could handle the path part for you.

Example from [System.UriBuilder]::new("@")
PSMessageDetails      : 
Exception             : System.Management.Automation.MethodInvocationException: Exception calling ".ctor" with "1" 
                        argument(s): "Invalid URI: The hostname could not be parsed."
                         ---> System.UriFormatException: Invalid URI: The hostname could not be parsed.
                           at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& 
                        creationOptions)
                           at System.Uri..ctor(String uriString)
                           at System.UriBuilder..ctor(String uri)
                           at CallSite.Target(Closure , CallSite , Type , String )
                           --- End of inner exception stack trace ---
                           at 
                        System.Management.Automation.ExceptionHandlingOps.ConvertToMethodInvocationException(Exception 
                        exception, Type typeToThrow, String methodName, Int32 numArgs, MemberInfo memberInfo)
                           at CallSite.Target(Closure , CallSite , Type , String )
                           at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
                           at System.Management.Automation.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame)
                           at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame 
                        frame)
TargetObject          : 
CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
FullyQualifiedErrorId : UriFormatException
ErrorDetails          : 
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}



MyCommand             : 
BoundParameters       : {}
UnboundArguments      : {}
ScriptLineNumber      : 1
OffsetInLine          : 1
HistoryId             : -1
ScriptName            : 
Line                  : [System.UriBuilder]::new("@")
PositionMessage       : At line:1 char:1
                        + [System.UriBuilder]::new("@")
                        + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PSScriptRoot          : 
PSCommandPath         : 
InvocationName        : 
PipelineLength        : 0
PipelinePosition      : 0
ExpectingInput        : False
CommandOrigin         : Internal
DisplayScriptPosition : 


00000000000000000000000000000000000000000000000000000000000000000000000000000000

ErrorRecord                 : Exception calling ".ctor" with "1" argument(s): "Invalid URI: The hostname could not be 
                              parsed."
WasThrownFromThrowStatement : False
TargetSite                  : Void ConvertToMethodInvocationException(System.Exception, System.Type, System.String, Int32, 
                              System.Reflection.MemberInfo)
Message                     : Exception calling ".ctor" with "1" argument(s): "Invalid URI: The hostname could not be 
                              parsed."
Data                        : {System.Management.Automation.Interpreter.InterpretedFrameInfo}
InnerException              : System.UriFormatException: Invalid URI: The hostname could not be parsed.
                                 at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, 
                              UriCreationOptions& creationOptions)
                                 at System.Uri..ctor(String uriString)
                                 at System.UriBuilder..ctor(String uri)
                                 at CallSite.Target(Closure , CallSite , Type , String )
HelpLink                    : 
Source                      : System.Management.Automation
HResult                     : -2146233087
StackTrace                  :    at System.Management.Automation.ExceptionHandlingOps.ConvertToMethodInvocationException(Exc
                              eption exception, Type typeToThrow, String methodName, Int32 numArgs, MemberInfo memberInfo)
                                 at CallSite.Target(Closure , CallSite , Type , String )
                                 at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 
                              arg1)
                                 at System.Management.Automation.Interpreter.DynamicInstruction`3.Run(InterpretedFrame 
                              frame)
                                 at 
                              System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame 
                              frame)


11111111111111111111111111111111111111111111111111111111111111111111111111111111

TargetSite     : Void CreateThis(System.String, Boolean, System.UriKind, System.UriCreationOptions ByRef)
Message        : Invalid URI: The hostname could not be parsed.
Data           : {}
InnerException : 
HelpLink       : 
Source         : System.Private.Uri
HResult        : -2146233033
StackTrace     :    at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& 
                 creationOptions)
                    at System.Uri..ctor(String uriString)
                    at System.UriBuilder..ctor(String uri)
                    at CallSite.Target(Closure , CallSite , Type , String )

Relevant code:

public static string AssemblyPath
{
get
{
string codeBase = Assembly.GetExecutingAssembly().Location;
UriBuilder uri = new(codeBase);
return Uri.UnescapeDataString(uri.Path);
}
}


New error with URI
PSMessageDetails      : 
Exception             : System.UriFormatException: Invalid URI: The hostname could not be parsed.
                           at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& 
                        creationOptions)
                           at System.Uri..ctor(String uriString)
                           at System.UriBuilder..ctor(String uri)
                           at PowerType.EnablePowerTypePredictor.get_AssemblyPath() in 
                        D:\a\PowerType\PowerType\PowerType\EnablePowerTypePredictor.cs:line 70
                           at PowerType.EnablePowerTypePredictor.get_ModuleDirectory() in 
                        D:\a\PowerType\PowerType\PowerType\EnablePowerTypePredictor.cs:line 76
                           at PowerType.EnablePowerTypePredictor.get_DictionariesDirectory() in 
                        D:\a\PowerType\PowerType\PowerType\EnablePowerTypePredictor.cs:line 78
                           at PowerType.EnablePowerTypePredictor.GetDictionaries()+MoveNext() in 
                        D:\a\PowerType\PowerType\PowerType\EnablePowerTypePredictor.cs:line 82
                           at PowerType.PowerTypePredictor..ctor(ICurrentWorkingDirectoryProvider 
                        currentWorkingDirectoryProvider, IEnumerable`1 dictionaryFiles) in 
                        D:\a\PowerType\PowerType\PowerType\PowerTypePredictor.cs:line 30
                           at PowerType.EnablePowerTypePredictor.ProcessRecord() in 
                        D:\a\PowerType\PowerType\PowerType\EnablePowerTypePredictor.cs:line 56
                           at System.Management.Automation.Cmdlet.DoProcessRecord()
                           at System.Management.Automation.CommandProcessor.ProcessRecord()
TargetObject          : 
CategoryInfo          : NotSpecified: (:) [Enable-PowerType], UriFormatException
FullyQualifiedErrorId : System.UriFormatException,PowerType.EnablePowerTypePredictor
ErrorDetails          : 
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}



MyCommand             : Enable-PowerType
BoundParameters       : {}
UnboundArguments      : {}
ScriptLineNumber      : 1
OffsetInLine          : 1
HistoryId             : 4
ScriptName            : 
Line                  : Enable-PowerType
PositionMessage       : At line:1 char:1
                        + Enable-PowerType
                        + ~~~~~~~~~~~~~~~~
PSScriptRoot          : 
PSCommandPath         : 
InvocationName        : Enable-PowerType
PipelineLength        : 0
PipelinePosition      : 0
ExpectingInput        : False
CommandOrigin         : Internal
DisplayScriptPosition : 


00000000000000000000000000000000000000000000000000000000000000000000000000000000

TargetSite     : Void CreateThis(System.String, Boolean, System.UriKind, System.UriCreationOptions ByRef)
Message        : Invalid URI: The hostname could not be parsed.
Data           : {}
InnerException : 
HelpLink       : 
Source         : System.Private.Uri
HResult        : -2146233033
StackTrace     :    at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& 
                 creationOptions)
                    at System.Uri..ctor(String uriString)
                    at System.UriBuilder..ctor(String uri)
                    at PowerType.EnablePowerTypePredictor.get_AssemblyPath() in 
                 D:\a\PowerType\PowerType\PowerType\EnablePowerTypePredictor.cs:line 70
                    at PowerType.EnablePowerTypePredictor.get_ModuleDirectory() in 
                 D:\a\PowerType\PowerType\PowerType\EnablePowerTypePredictor.cs:line 76
                    at PowerType.EnablePowerTypePredictor.get_DictionariesDirectory() in 
                 D:\a\PowerType\PowerType\PowerType\EnablePowerTypePredictor.cs:line 78
                    at PowerType.EnablePowerTypePredictor.GetDictionaries()+MoveNext() in 
                 D:\a\PowerType\PowerType\PowerType\EnablePowerTypePredictor.cs:line 82
                    at PowerType.PowerTypePredictor..ctor(ICurrentWorkingDirectoryProvider currentWorkingDirectoryProvider, 
                 IEnumerable`1 dictionaryFiles) in D:\a\PowerType\PowerType\PowerType\PowerTypePredictor.cs:line 30
                    at PowerType.EnablePowerTypePredictor.ProcessRecord() in 
                 D:\a\PowerType\PowerType\PowerType\EnablePowerTypePredictor.cs:line 56
                    at System.Management.Automation.Cmdlet.DoProcessRecord()
                    at System.Management.Automation.CommandProcessor.ProcessRecord()

from powertype.

AnderssonPeter avatar AnderssonPeter commented on June 3, 2024

Sorry for the huge delay, if you have the time, could you create a unit test that recreates the issue and create a fix and send them as a PR?

from powertype.

fluentmoheshwar avatar fluentmoheshwar commented on June 3, 2024

I get this error in Ubuntu

Enable-PowerType: Invalid URI: The hostname could not be parsed.

from powertype.

AnderssonPeter avatar AnderssonPeter commented on June 3, 2024

Guessing the issue is on all Linux based systems.
I don't currently have a linux install with powershell.
If you can provide a unit test that recreates the issue then I might be able to fix it!

from powertype.

fluentmoheshwar avatar fluentmoheshwar commented on June 3, 2024

Guessing the issue is on all Linux based systems.
I don't currently have a linux install with powershell.
If you can provide a unit test that recreates the issue then I might be able to fix it!

Well, I don't have experience in C# so I don't think I can do it :) you could just use a VM or WSL might work ;)

from powertype.

AnderssonPeter avatar AnderssonPeter commented on June 3, 2024

@fluentmoheshwar @Ampflower Could you guys try 0.0.16 and see if that solves the issue?

from powertype.

AnderssonPeter avatar AnderssonPeter commented on June 3, 2024

Great :) sorry that it took so much time to fix the issue.

from powertype.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.