Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

A dictionary type that only implements the generic IDictionary interface doesn't support dot notation (property-access syntax) #17190

Copy link
Copy link
@mklement0

Description

@mklement0
Issue body actions

Prerequisites

Steps to reproduce

Related:

[Tomlyn.Model.TomlTable], from the Tomlyn package, is an example of a type that implements IDictionary`2, but not also its non-generic counterpart, IDictionary.

Seemingly, this prevents use of dot notation (property-access syntax via the member-access operator) to access the dictionary's entries.

# Determine the package's local installation location.
# If it isn't installed, install it first, in the current user's scope.
while (-not ($installDir = (Get-Package -ErrorAction Ignore -ProviderName NuGet Tomlyn).Source)) {
  $null = Install-Package -Scope CurrentUser -ErrorAction Stop -ProviderName NuGet Tomlyn
}

# Load the package's assembly into the session.
Add-Type -ErrorAction Stop -LiteralPath (Join-Path $installDir '../lib/netstandard2.0/Tomlyn.dll')

# Define a sample TOML string to parse.
$tomlStr = @'
foo = "bar"
'@

# Parse the TOML string into an object mod)el (nested dictionaries).
$tomlTable = [Tomlyn.Toml]::ToModel($tomlStr)

# Output the global section's 'foo' value,
# first via an indexer, then via dot notation.
$tomlTable['foo'], $tomlTable.foo | ForEach-Object { "[$_]" }

Expected behavior

[bar]
[bar]

Actual behavior

[bar]
[]

Error details

No response

Environment data

PowerShell Core 7.3.0-preview.3

Visuals

No response

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.