-
Notifications
You must be signed in to change notification settings - Fork 382
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1195 from rjmholt/case-sensitive-type-collection
Prevent .NET members with names differing only by case from crashing the compatibility profiler
- Loading branch information
Showing
7 changed files
with
82 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
|
||
Describe ".NET type with members with names differing only by name" { | ||
BeforeAll { | ||
Add-Type -TypeDefinition @' | ||
namespace PSScriptAnalyzerTests | ||
{ | ||
public class QueryApiTestObject | ||
{ | ||
public string JobId { get; set; } | ||
public object JOBID { get; set; } | ||
} | ||
} | ||
'@ | ||
} | ||
|
||
It "Does not crash the query API" { | ||
$typeData = [Microsoft.PowerShell.CrossCompatibility.Utility.TypeDataConversion]::AssembleType([PSScriptAnalyzerTests.QueryApiTestObject]) | ||
|
||
$typeQueryObject = New-Object 'Microsoft.PowerShell.CrossCompatibility.Query.TypeData' ('QueryApiTestObject', $typeData) | ||
|
||
$typeData.Instance.Properties.Count | Should -Be 2 | ||
|
||
$typeData.Instance.Properties.ContainsKey('JobId') | Should -BeTrue | ||
$typeData.Instance.Properties.ContainsKey('JOBID') | Should -BeTrue | ||
$typeData.Instance.Properties.ContainsKey('jobid') | Should -Not -BeTrue | ||
|
||
$typeQueryObject.Instance.Properties.Count | Should -Be 1 | ||
|
||
$typeQueryObject.Instance.Properties.ContainsKey('JobId') | Should -BeTrue | ||
$typeQueryObject.Instance.Properties.ContainsKey('JobID') | Should -BeTrue | ||
$typeQueryObject.Instance.Properties.ContainsKey('jobid') | Should -BeTrue | ||
} | ||
} |