powershellhtml-agility-pack

Is Powershell giving me a method that actually exists?


I am trying to figure out how to use the HtmlAgilityPack.dll library, of which I have version 1.11.59. Till now I have been using it indirectly, through the PSParseHTML.

Since its not a Microsoft product, I cant just pull up its ms web page for one of its methods.

Relying on PowerShell, if I start typing $html.DocumentNode.GetAttribute, PowerShell suggest method signatures:

string GetAttributeValue(string name, string def)
int GetAttributeValue(string name, int def)
bool GetAttributeValue(string name, bool def)
T GetAttributeValue[T](string name, T def)

I have tried to find online documentation for these methods to learn more about them and I have not found any documentation for this method. The official documentation for htmlAqilityPack does not list the above method.

So am wondering what is the source of it? This is my beyond my usual area, so I could overlooking something.

I am on PowerShell v7.4


Solution

  • Building on Mathias' helpful comment:


    [1] Note an inconsistency in how PowerShell reports these signatures: While referring to types in PowerShell normally requires enclosing their names in [...], e.g. [string], the method-signature notation uses C#-style type-name-only references, e.g. string - except in the case of generic type arguments (e.g. ... GetAttributeValue[T](...), where [T] contrasts with .NET's <T> notation.)

    [2] For instance, in Windows PowerShell (the legacy, ships-with-Windows, Windows-only edition of PowerShell whose latest and last version is 5.1) you cannot call methods that require generic type parameters (except if there's only one and only if that type can be inferred from the call's arguments). PowerShell (Core) 7 now supports such calls, but neither edition supports use of ByRef-like types (ref struct in C#), such as System.Span<T>