sanvlr12 / google-api-dotnet-client

Automatically exported from code.google.com/p/google-api-dotnet-client
0 stars 0 forks source link

Scopes class with const strings #144

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. PlusService.Scopes.PlusMe doesn't convert to a string without a proper 
annotation
2. Add the following line to a C# file that references the G+ .NET Api v1

string scopeUri = PlusService.Scopes.PlusMe;

What is the expected output? What do you see instead?
Expected output is that PlusService.Scopes.PlusMe would be converted to a 
string representation of the scope URI (https://www.googleapis.com/auth/plus.me)

Instead, VisualStudio throws an error "Cannot implicitly convert type 
'Google.Apis.Plus.v1.PlusService.Scopes' to 'string'"   

See line 2024 in the below mentioned .cs file, there's no 
System.ComponentModel.TypeConverterAttribute on the enum Scopes.

See line 2067 for a working version (ActivitiesResource.Collection.Public 
converts nicely to the string "public" due to the annotation on the public enum 
Collection

[System.ComponentModel.TypeConverterAttribute(typeof(Google.Apis.Util.EnumString
ValueTypeConverter))]

What version of the product are you using? On what operating system?
http://code.google.com/p/google-api-dotnet-client/wiki/APIs#Google+_API

http://contrib.google-api-dotnet-client.googlecode.com/hg/Stable/Generated/Sourc
e/Google.Apis.Plus.v1.cs

Please provide any additional information below.

Original issue reported on code.google.com by asky...@google.com on 17 Sep 2011 at 8:22

GoogleCodeExporter commented 9 years ago
The current method is to use the .GetStringValue() extension method:

string scopeUri = PlusService.Scopes.PlusMe.GetStringValue();

This design should probably be revisited so I am going to keep this bug open 
for now.

Original comment by asky...@google.com on 17 Sep 2011 at 8:26

GoogleCodeExporter commented 9 years ago
The problem is that you can't override the .ToString() method. We don't have 
that issue when using Enums for data input as the library manually checks for a 
proper TypeConverter, and uses it if available.

Maybe the CodeGenerator create a nested static class "Scopes" instead, which 
contains every scope as a constant?

Original comment by mlinder...@gmail.com on 17 Sep 2011 at 8:57

GoogleCodeExporter commented 9 years ago

Original comment by asky...@google.com on 27 Oct 2011 at 5:40

GoogleCodeExporter commented 9 years ago
Needs significant rework, moving to 1.2 beta for deeper consideration.

Original comment by asky...@google.com on 5 Nov 2011 at 6:01

GoogleCodeExporter commented 9 years ago
Issue 162 has been merged into this issue.

Original comment by asky...@google.com on 5 Nov 2011 at 6:03

GoogleCodeExporter commented 9 years ago

Original comment by asky...@google.com on 25 Apr 2012 at 4:25

GoogleCodeExporter commented 9 years ago
We should change the scopes enum to scopes class that contains strings with all 
the scopes.

Original comment by pele...@google.com on 6 Sep 2013 at 6:56

GoogleCodeExporter commented 9 years ago

Original comment by pele...@google.com on 6 Sep 2013 at 6:56

GoogleCodeExporter commented 9 years ago

Original comment by pele...@google.com on 14 Sep 2013 at 1:53

GoogleCodeExporter commented 9 years ago

Original comment by pele...@google.com on 3 Oct 2013 at 7:29