aerospike / aerospike-client-csharp

Aerospike C# Client Library
70 stars 47 forks source link

Changed Default to DefaultProp to make it Common Language Specificati… #47

Closed brunoyin closed 4 years ago

brunoyin commented 4 years ago

The public policy variables and public policy properties have differ only in first character lower/upper cases. This is not Common Language Specification (CLS) compliant. And It does not work in Powershell.

By simply renaming Default to DefaultProp correct the problem

Add-Type -Path .\AerospikeClient.dll
$client = [Aerospike.Client.AerospikeClient]::new($clientPolicy, '192.168.1.250', 3000)
# ...
# client put will generate errors
$client.Put( ... )

# The field or property: "readPolicyDefault" for type: "Aerospike.Client.AerospikeClient" differs only in 
# letter casing from the field or property: "ReadPolicyDefault". The type must be Common Language Specification (CLS) compliant.
# At line:9 char:5
# +     $client.Put($policy, $key, $bins[0],$bins[1],$bins[2],$bins[3],$b ...
# +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# + CategoryInfo          : NotSpecified: (:) [], ExtendedTypeSystemException
# + FullyQualifiedErrorId : NotACLSComplaintField
BrianNichols commented 4 years ago

There is a way to retrieve policy defaults from PowerShell without breaking the AerospikeClient API.

https://www.catapultsystems.com/blogs/using-non-cls-compliant-types-in-powershell/

brunoyin commented 4 years ago

There is no good reason to be non CLS compliant. No good reason to have a public property and public variable with the same name.

I would guess that the original author accidentally made the variables with the same names public, the variables normally should be privately especially when you have a public property with an identical name.