fix c# net35 issue, add xml doc to new C# class (#5756)

This commit is contained in:
wing328 2017-06-01 07:53:35 +08:00 committed by GitHub
parent 98684d872c
commit 08a11c1d75
16 changed files with 272 additions and 33 deletions

View File

@ -212,6 +212,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
additionalProperties.remove("supportsAsync"); additionalProperties.remove("supportsAsync");
} }
additionalProperties.put("validatable", false); additionalProperties.put("validatable", false);
additionalProperties.put("net35", true);
} else if (NETSTANDARD.equals(this.targetFramework)){ } else if (NETSTANDARD.equals(this.targetFramework)){
setTargetFrameworkNuget("netstandard1.3"); setTargetFrameworkNuget("netstandard1.3");
setSupportsAsync(Boolean.TRUE); setSupportsAsync(Boolean.TRUE);

View File

@ -1,7 +1,9 @@
{{>partial_header}} {{>partial_header}}
using System; using System;
using System.Reflection; using System.Reflection;
{{^net35}}
using System.Collections.Concurrent; using System.Collections.Concurrent;
{{/net35}}
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@ -107,9 +109,9 @@ namespace {{packageName}}.Client
{ {
UserAgent = "{{#httpUserAgent}}{{.}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{packageVersion}}/csharp{{/httpUserAgent}}"; UserAgent = "{{#httpUserAgent}}{{.}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{packageVersion}}/csharp{{/httpUserAgent}}";
BasePath = "{{{basePath}}}"; BasePath = "{{{basePath}}}";
DefaultHeader = new ConcurrentDictionary<string, string>(); DefaultHeader = new {{^net35}}Concurrent{{/net35}}Dictionary<string, string>();
ApiKey = new ConcurrentDictionary<string, string>(); ApiKey = new {{^net35}}Concurrent{{/net35}}Dictionary<string, string>();
ApiKeyPrefix = new ConcurrentDictionary<string, string>(); ApiKeyPrefix = new {{^net35}}Concurrent{{/net35}}Dictionary<string, string>();
// Setting Timeout has side effects (forces ApiClient creation). // Setting Timeout has side effects (forces ApiClient creation).
Timeout = 100000; Timeout = 100000;
@ -124,7 +126,7 @@ namespace {{packageName}}.Client
IDictionary<string, string> apiKeyPrefix, IDictionary<string, string> apiKeyPrefix,
string basePath = "{{{basePath}}}") : this() string basePath = "{{{basePath}}}") : this()
{ {
if (string.IsNullOrWhiteSpace(basePath)) if (string.{{^net35}}IsNullOrWhiteSpace{{/net35}}{{#net35}}IsNullOrEmpty{{/net35}}(basePath))
throw new ArgumentException("The provided basePath is invalid.", "basePath"); throw new ArgumentException("The provided basePath is invalid.", "basePath");
if (defaultHeader == null) if (defaultHeader == null)
throw new ArgumentNullException("defaultHeader"); throw new ArgumentNullException("defaultHeader");
@ -264,7 +266,7 @@ namespace {{packageName}}.Client
public virtual string Password { get; set; } public virtual string Password { get; set; }
/// <summary> /// <summary>
/// Gets or sets the access token for OAuth2 authentication. /// Gets the API key with prefix.
/// </summary> /// </summary>
/// <param name="apiKeyIdentifier">API key identifier (authentication scheme).</param> /// <param name="apiKeyIdentifier">API key identifier (authentication scheme).</param>
/// <returns>API key with prefix.</returns> /// <returns>API key with prefix.</returns>

View File

@ -9,18 +9,77 @@ namespace {{packageName}}.Client
/// </summary> /// </summary>
public interface IReadableConfiguration public interface IReadableConfiguration
{ {
/// <summary>
/// Gets the access token.
/// </summary>
/// <value>Access token.</value>
string AccessToken { get; } string AccessToken { get; }
/// <summary>
/// Gets the API key.
/// </summary>
/// <value>API key.</value>
IDictionary<string, string> ApiKey { get; } IDictionary<string, string> ApiKey { get; }
/// <summary>
/// Gets the API key prefix.
/// </summary>
/// <value>API key prefix.</value>
IDictionary<string, string> ApiKeyPrefix { get; } IDictionary<string, string> ApiKeyPrefix { get; }
/// <summary>
/// Gets the base path.
/// </summary>
/// <value>Base path.</value>
string BasePath { get; } string BasePath { get; }
/// <summary>
/// Gets the date time format.
/// </summary>
/// <value>Date time foramt.</value>
string DateTimeFormat { get; } string DateTimeFormat { get; }
/// <summary>
/// Gets the default header.
/// </summary>
/// <value>Default header.</value>
IDictionary<string, string> DefaultHeader { get; } IDictionary<string, string> DefaultHeader { get; }
string Password { get; }
/// <summary>
/// Gets the temp folder path.
/// </summary>
/// <value>Temp folder path.</value>
string TempFolderPath { get; } string TempFolderPath { get; }
/// <summary>
/// Gets the HTTP connection timeout (in milliseconds)
/// </summary>
/// <value>HTTP connection timeout.</value>
int Timeout { get; } int Timeout { get; }
/// <summary>
/// Gets the user agent.
/// </summary>
/// <value>User agent.</value>
string UserAgent { get; } string UserAgent { get; }
/// <summary>
/// Gets the username.
/// </summary>
/// <value>Username.</value>
string Username { get; } string Username { get; }
/// <summary>
/// Gets the password.
/// </summary>
/// <value>Password.</value>
string Password { get; }
/// <summary>
/// Gets the API key with prefix.
/// </summary>
/// <param name="apiKeyIdentifier">API key identifier (authentication scheme).</param>
/// <returns>API key with prefix.</returns>
string GetApiKeyWithPrefix(string apiKeyIdentifier); string GetApiKeyWithPrefix(string apiKeyIdentifier);
} }
} }

View File

@ -157,7 +157,7 @@ namespace {{packageName}}.{{apiPackage}}
[Obsolete("DefaultHeader is deprecated, please use Configuration.DefaultHeader instead.")] [Obsolete("DefaultHeader is deprecated, please use Configuration.DefaultHeader instead.")]
public IDictionary<String, String> DefaultHeader() public IDictionary<String, String> DefaultHeader()
{ {
return new ReadOnlyDictionary<string, string>(this.Configuration.DefaultHeader); return new {{^net35}}ReadOnly{{/net35}}Dictionary<string, string>(this.Configuration.DefaultHeader);
} }
/// <summary> /// <summary>

View File

@ -293,9 +293,9 @@ namespace Example
public void main() public void main()
{ {
// Configure API key authorization: api_key // Configure API key authorization: api_key
Configuration.Default.ApiKey.Add("api_key", "YOUR_API_KEY"); Configuration.Default.AddApiKey("api_key", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Configuration.Default.ApiKeyPrefix.Add("api_key", "Bearer"); // Configuration.Default.AddApiKeyPrefix("api_key", "Bearer");
var apiInstance = new PetApi(); var apiInstance = new PetApi();
var petId = 789; // long? | ID of pet to return var petId = 789; // long? | ID of pet to return

View File

@ -93,9 +93,9 @@ namespace Example
public void main() public void main()
{ {
// Configure API key authorization: api_key // Configure API key authorization: api_key
Configuration.Default.ApiKey.Add("api_key", "YOUR_API_KEY"); Configuration.Default.AddApiKey("api_key", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Configuration.Default.ApiKeyPrefix.Add("api_key", "Bearer"); // Configuration.Default.AddApiKeyPrefix("api_key", "Bearer");
var apiInstance = new StoreApi(); var apiInstance = new StoreApi();

View File

@ -272,7 +272,7 @@ namespace IO.Swagger.Client
public virtual string Password { get; set; } public virtual string Password { get; set; }
/// <summary> /// <summary>
/// Gets or sets the access token for OAuth2 authentication. /// Gets the API key with prefix.
/// </summary> /// </summary>
/// <param name="apiKeyIdentifier">API key identifier (authentication scheme).</param> /// <param name="apiKeyIdentifier">API key identifier (authentication scheme).</param>
/// <returns>API key with prefix.</returns> /// <returns>API key with prefix.</returns>

View File

@ -18,18 +18,77 @@ namespace IO.Swagger.Client
/// </summary> /// </summary>
public interface IReadableConfiguration public interface IReadableConfiguration
{ {
/// <summary>
/// Gets the access token.
/// </summary>
/// <value>Access token.</value>
string AccessToken { get; } string AccessToken { get; }
/// <summary>
/// Gets the API key.
/// </summary>
/// <value>API key.</value>
IDictionary<string, string> ApiKey { get; } IDictionary<string, string> ApiKey { get; }
/// <summary>
/// Gets the API key prefix.
/// </summary>
/// <value>API key prefix.</value>
IDictionary<string, string> ApiKeyPrefix { get; } IDictionary<string, string> ApiKeyPrefix { get; }
/// <summary>
/// Gets the base path.
/// </summary>
/// <value>Base path.</value>
string BasePath { get; } string BasePath { get; }
/// <summary>
/// Gets the date time format.
/// </summary>
/// <value>Date time foramt.</value>
string DateTimeFormat { get; } string DateTimeFormat { get; }
/// <summary>
/// Gets the default header.
/// </summary>
/// <value>Default header.</value>
IDictionary<string, string> DefaultHeader { get; } IDictionary<string, string> DefaultHeader { get; }
string Password { get; }
/// <summary>
/// Gets the temp folder path.
/// </summary>
/// <value>Temp folder path.</value>
string TempFolderPath { get; } string TempFolderPath { get; }
/// <summary>
/// Gets the HTTP connection timeout (in milliseconds)
/// </summary>
/// <value>HTTP connection timeout.</value>
int Timeout { get; } int Timeout { get; }
/// <summary>
/// Gets the user agent.
/// </summary>
/// <value>User agent.</value>
string UserAgent { get; } string UserAgent { get; }
/// <summary>
/// Gets the username.
/// </summary>
/// <value>Username.</value>
string Username { get; } string Username { get; }
/// <summary>
/// Gets the password.
/// </summary>
/// <value>Password.</value>
string Password { get; }
/// <summary>
/// Gets the API key with prefix.
/// </summary>
/// <param name="apiKeyIdentifier">API key identifier (authentication scheme).</param>
/// <returns>API key with prefix.</returns>
string GetApiKeyWithPrefix(string apiKeyIdentifier); string GetApiKeyWithPrefix(string apiKeyIdentifier);
} }
} }

View File

@ -293,9 +293,9 @@ namespace Example
public void main() public void main()
{ {
// Configure API key authorization: api_key // Configure API key authorization: api_key
Configuration.Default.ApiKey.Add("api_key", "YOUR_API_KEY"); Configuration.Default.AddApiKey("api_key", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Configuration.Default.ApiKeyPrefix.Add("api_key", "Bearer"); // Configuration.Default.AddApiKeyPrefix("api_key", "Bearer");
var apiInstance = new PetApi(); var apiInstance = new PetApi();
var petId = 789; // long? | ID of pet to return var petId = 789; // long? | ID of pet to return

View File

@ -93,9 +93,9 @@ namespace Example
public void main() public void main()
{ {
// Configure API key authorization: api_key // Configure API key authorization: api_key
Configuration.Default.ApiKey.Add("api_key", "YOUR_API_KEY"); Configuration.Default.AddApiKey("api_key", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Configuration.Default.ApiKeyPrefix.Add("api_key", "Bearer"); // Configuration.Default.AddApiKeyPrefix("api_key", "Bearer");
var apiInstance = new StoreApi(); var apiInstance = new StoreApi();

View File

@ -267,7 +267,7 @@ namespace IO.Swagger.Client
public virtual string Password { get; set; } public virtual string Password { get; set; }
/// <summary> /// <summary>
/// Gets or sets the access token for OAuth2 authentication. /// Gets the API key with prefix.
/// </summary> /// </summary>
/// <param name="apiKeyIdentifier">API key identifier (authentication scheme).</param> /// <param name="apiKeyIdentifier">API key identifier (authentication scheme).</param>
/// <returns>API key with prefix.</returns> /// <returns>API key with prefix.</returns>

View File

@ -18,18 +18,77 @@ namespace IO.Swagger.Client
/// </summary> /// </summary>
public interface IReadableConfiguration public interface IReadableConfiguration
{ {
/// <summary>
/// Gets the access token.
/// </summary>
/// <value>Access token.</value>
string AccessToken { get; } string AccessToken { get; }
/// <summary>
/// Gets the API key.
/// </summary>
/// <value>API key.</value>
IDictionary<string, string> ApiKey { get; } IDictionary<string, string> ApiKey { get; }
/// <summary>
/// Gets the API key prefix.
/// </summary>
/// <value>API key prefix.</value>
IDictionary<string, string> ApiKeyPrefix { get; } IDictionary<string, string> ApiKeyPrefix { get; }
/// <summary>
/// Gets the base path.
/// </summary>
/// <value>Base path.</value>
string BasePath { get; } string BasePath { get; }
/// <summary>
/// Gets the date time format.
/// </summary>
/// <value>Date time foramt.</value>
string DateTimeFormat { get; } string DateTimeFormat { get; }
/// <summary>
/// Gets the default header.
/// </summary>
/// <value>Default header.</value>
IDictionary<string, string> DefaultHeader { get; } IDictionary<string, string> DefaultHeader { get; }
string Password { get; }
/// <summary>
/// Gets the temp folder path.
/// </summary>
/// <value>Temp folder path.</value>
string TempFolderPath { get; } string TempFolderPath { get; }
/// <summary>
/// Gets the HTTP connection timeout (in milliseconds)
/// </summary>
/// <value>HTTP connection timeout.</value>
int Timeout { get; } int Timeout { get; }
/// <summary>
/// Gets the user agent.
/// </summary>
/// <value>User agent.</value>
string UserAgent { get; } string UserAgent { get; }
/// <summary>
/// Gets the username.
/// </summary>
/// <value>Username.</value>
string Username { get; } string Username { get; }
/// <summary>
/// Gets the password.
/// </summary>
/// <value>Password.</value>
string Password { get; }
/// <summary>
/// Gets the API key with prefix.
/// </summary>
/// <param name="apiKeyIdentifier">API key identifier (authentication scheme).</param>
/// <returns>API key with prefix.</returns>
string GetApiKeyWithPrefix(string apiKeyIdentifier); string GetApiKeyWithPrefix(string apiKeyIdentifier);
} }
} }

View File

@ -293,9 +293,9 @@ namespace Example
public void main() public void main()
{ {
// Configure API key authorization: api_key // Configure API key authorization: api_key
Configuration.Default.ApiKey.Add("api_key", "YOUR_API_KEY"); Configuration.Default.AddApiKey("api_key", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Configuration.Default.ApiKeyPrefix.Add("api_key", "Bearer"); // Configuration.Default.AddApiKeyPrefix("api_key", "Bearer");
var apiInstance = new PetApi(); var apiInstance = new PetApi();
var petId = 789; // long? | ID of pet to return var petId = 789; // long? | ID of pet to return

View File

@ -93,9 +93,9 @@ namespace Example
public void main() public void main()
{ {
// Configure API key authorization: api_key // Configure API key authorization: api_key
Configuration.Default.ApiKey.Add("api_key", "YOUR_API_KEY"); Configuration.Default.AddApiKey("api_key", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Configuration.Default.ApiKeyPrefix.Add("api_key", "Bearer"); // Configuration.Default.AddApiKeyPrefix("api_key", "Bearer");
var apiInstance = new StoreApi(); var apiInstance = new StoreApi();

View File

@ -272,7 +272,7 @@ namespace IO.Swagger.Client
public virtual string Password { get; set; } public virtual string Password { get; set; }
/// <summary> /// <summary>
/// Gets or sets the access token for OAuth2 authentication. /// Gets the API key with prefix.
/// </summary> /// </summary>
/// <param name="apiKeyIdentifier">API key identifier (authentication scheme).</param> /// <param name="apiKeyIdentifier">API key identifier (authentication scheme).</param>
/// <returns>API key with prefix.</returns> /// <returns>API key with prefix.</returns>

View File

@ -18,18 +18,77 @@ namespace IO.Swagger.Client
/// </summary> /// </summary>
public interface IReadableConfiguration public interface IReadableConfiguration
{ {
/// <summary>
/// Gets the access token.
/// </summary>
/// <value>Access token.</value>
string AccessToken { get; } string AccessToken { get; }
/// <summary>
/// Gets the API key.
/// </summary>
/// <value>API key.</value>
IDictionary<string, string> ApiKey { get; } IDictionary<string, string> ApiKey { get; }
/// <summary>
/// Gets the API key prefix.
/// </summary>
/// <value>API key prefix.</value>
IDictionary<string, string> ApiKeyPrefix { get; } IDictionary<string, string> ApiKeyPrefix { get; }
/// <summary>
/// Gets the base path.
/// </summary>
/// <value>Base path.</value>
string BasePath { get; } string BasePath { get; }
/// <summary>
/// Gets the date time format.
/// </summary>
/// <value>Date time foramt.</value>
string DateTimeFormat { get; } string DateTimeFormat { get; }
/// <summary>
/// Gets the default header.
/// </summary>
/// <value>Default header.</value>
IDictionary<string, string> DefaultHeader { get; } IDictionary<string, string> DefaultHeader { get; }
string Password { get; }
/// <summary>
/// Gets the temp folder path.
/// </summary>
/// <value>Temp folder path.</value>
string TempFolderPath { get; } string TempFolderPath { get; }
/// <summary>
/// Gets the HTTP connection timeout (in milliseconds)
/// </summary>
/// <value>HTTP connection timeout.</value>
int Timeout { get; } int Timeout { get; }
/// <summary>
/// Gets the user agent.
/// </summary>
/// <value>User agent.</value>
string UserAgent { get; } string UserAgent { get; }
/// <summary>
/// Gets the username.
/// </summary>
/// <value>Username.</value>
string Username { get; } string Username { get; }
/// <summary>
/// Gets the password.
/// </summary>
/// <value>Password.</value>
string Password { get; }
/// <summary>
/// Gets the API key with prefix.
/// </summary>
/// <param name="apiKeyIdentifier">API key identifier (authentication scheme).</param>
/// <returns>API key with prefix.</returns>
string GetApiKeyWithPrefix(string apiKeyIdentifier); string GetApiKeyWithPrefix(string apiKeyIdentifier);
} }
} }