REQ: Don't throw for a class with member names differing by only by casing
See original GitHub issueSteps to reproduce
Add-Type -TypeDefinition 'public enum Testing { Yes, yes }'
[Testing] | Get-Member -Static
Expected behavior
Either get both “Yes” members, or just the last one processed. Mainly I’d expect it not to throw.
Actual behavior
Get-Member : The field or property: "yes" for type: "Testing" differs only in letter casing from the field or property: "Yes". The type must be Common Language Specification (CLS) compliant.
At line:1 char:13
+ [Testing] | Get-Member -Static
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-Member], ExtendedTypeSystemException
+ FullyQualifiedErrorId : NotACLSComplaintField,Microsoft.PowerShell.Commands.GetMemberCommand
Environment data
Name Value
---- -----
PSVersion 7.0.0-preview.2
PSEdition Core
GitCommitId 7.0.0-preview.2
OS Microsoft Windows 10.0.18362
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Other
Here’s where it throws in DotNetAdapter.
I ran into this while writing something that uses dnlib. Their MethodAttributes enum has two values for PInvokeImpl
(~I’d guess they had the one with the incorrect casing originally and just added one with the right casing as to not break anyone. That’s just a guess though~ Actually looking at the rest, I think it’s because they’re using both the System.Reflection
names as well as the EMCA spec names.)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:33 (8 by maintainers)
Top Results From Across the Web
'File name differs from already included file name only in ...
The thing is, it compiles just fine on Mac and Linux, but throws this error on Windows. If it helps, forceConsistentCasingInFileNames is enabled ......
Read more >Is using parameter names that differ from type names only ...
The language itself is offering us a perfectly clear, unambiguous universally recognizable way of indicating we are dealing with a class member.
Read more >Methods and field names should not be the same or differ ...
This rule raises an issue when there is a method and a field in a class with names that differ only by capitalization....
Read more >ProGuard Manual: Usage
By default, ProGuard shrinks the code: it removes all unused classes and class members. It only keeps the ones listed by the various...
Read more >Model Binding in ASP.NET Core
Learn how model binding in ASP.NET Core works and how to customize its behavior.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@PowerShell/powershell-committee reviewed this, we propose the following behavior:
I think most .NET libraries are not CLS compliant and the reason is simple, most people use C#.
PowerShell shouldn’t throw in this case, it’s fine to say this is undefined behavior as long as it doesn’t throw.