Resolve namespace-identifier conflicts (#611)
This commit is contained in:
Родитель
4bf6422910
Коммит
8ef05f77c3
|
@ -190,6 +190,7 @@ namespace AutoRest.CSharp.V3.Generation.Writers
|
|||
{
|
||||
UseNamespace(type.Namespace);
|
||||
|
||||
AppendRaw("global::");
|
||||
AppendRaw(type.Namespace);
|
||||
AppendRaw(".");
|
||||
AppendRaw(type.Name);
|
||||
|
|
|
@ -11,7 +11,7 @@ schemas: !<!Schemas>
|
|||
name: String
|
||||
description: simple string
|
||||
protocol: !<!Protocols> {}
|
||||
- !<!StringSchema> &ref_105
|
||||
- !<!StringSchema> &ref_106
|
||||
type: string
|
||||
apiVersions:
|
||||
- !<!ApiVersion>
|
||||
|
@ -1051,8 +1051,33 @@ schemas: !<!Schemas>
|
|||
name: ClassYield
|
||||
description: ''
|
||||
protocol: !<!Protocols> {}
|
||||
choices:
|
||||
- !<!ChoiceSchema> &ref_104
|
||||
choices:
|
||||
- !<!ChoiceValue>
|
||||
value: System
|
||||
language:
|
||||
default:
|
||||
name: System
|
||||
description: ''
|
||||
- !<!ChoiceValue>
|
||||
value: System.Text.Json
|
||||
language:
|
||||
default:
|
||||
name: SystemTextJson
|
||||
description: ''
|
||||
type: choice
|
||||
apiVersions:
|
||||
- !<!ApiVersion>
|
||||
version: 1.0.0
|
||||
choiceType: *ref_0
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: SystemEnum
|
||||
description: ''
|
||||
protocol: !<!Protocols> {}
|
||||
constants:
|
||||
- !<!ConstantSchema> &ref_106
|
||||
- !<!ConstantSchema> &ref_107
|
||||
type: constant
|
||||
value: !<!ConstantValue>
|
||||
value: application/json
|
||||
|
@ -1063,7 +1088,7 @@ schemas: !<!Schemas>
|
|||
description: Content Type 'application/json'
|
||||
protocol: !<!Protocols> {}
|
||||
objects:
|
||||
- !<!ObjectSchema> &ref_107
|
||||
- !<!ObjectSchema> &ref_108
|
||||
type: object
|
||||
apiVersions:
|
||||
- !<!ApiVersion>
|
||||
|
@ -1893,6 +1918,14 @@ schemas: !<!Schemas>
|
|||
name: yield
|
||||
description: ''
|
||||
protocol: !<!Protocols> {}
|
||||
- !<!Property>
|
||||
schema: *ref_104
|
||||
serializedName: System
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: system
|
||||
description: ''
|
||||
protocol: !<!Protocols> {}
|
||||
serializationFormats:
|
||||
- json
|
||||
usage:
|
||||
|
@ -1905,7 +1938,7 @@ schemas: !<!Schemas>
|
|||
namespace: ''
|
||||
protocol: !<!Protocols> {}
|
||||
globalParameters:
|
||||
- !<!Parameter> &ref_104
|
||||
- !<!Parameter> &ref_105
|
||||
schema: *ref_0
|
||||
clientDefaultValue: 'http://localhost:3000'
|
||||
implementation: Client
|
||||
|
@ -1929,9 +1962,9 @@ operationGroups:
|
|||
- !<!ApiVersion>
|
||||
version: 1.0.0
|
||||
parameters:
|
||||
- *ref_104
|
||||
- !<!Parameter> &ref_109
|
||||
schema: *ref_105
|
||||
- *ref_105
|
||||
- !<!Parameter> &ref_110
|
||||
schema: *ref_106
|
||||
implementation: Method
|
||||
required: true
|
||||
language: !<!Languages>
|
||||
|
@ -1942,8 +1975,8 @@ operationGroups:
|
|||
protocol: !<!Protocols>
|
||||
http: !<!HttpParameter>
|
||||
in: query
|
||||
- !<!Parameter> &ref_110
|
||||
schema: *ref_105
|
||||
- !<!Parameter> &ref_111
|
||||
schema: *ref_106
|
||||
implementation: Method
|
||||
required: true
|
||||
language: !<!Languages>
|
||||
|
@ -1954,8 +1987,8 @@ operationGroups:
|
|||
protocol: !<!Protocols>
|
||||
http: !<!HttpParameter>
|
||||
in: query
|
||||
- !<!Parameter> &ref_111
|
||||
schema: *ref_105
|
||||
- !<!Parameter> &ref_112
|
||||
schema: *ref_106
|
||||
implementation: Method
|
||||
required: true
|
||||
language: !<!Languages>
|
||||
|
@ -1966,8 +1999,8 @@ operationGroups:
|
|||
protocol: !<!Protocols>
|
||||
http: !<!HttpParameter>
|
||||
in: query
|
||||
- !<!Parameter> &ref_112
|
||||
schema: *ref_105
|
||||
- !<!Parameter> &ref_113
|
||||
schema: *ref_106
|
||||
implementation: Method
|
||||
required: true
|
||||
language: !<!Languages>
|
||||
|
@ -1982,7 +2015,7 @@ operationGroups:
|
|||
- !<!Request>
|
||||
parameters:
|
||||
- !<!Parameter>
|
||||
schema: *ref_106
|
||||
schema: *ref_107
|
||||
implementation: Method
|
||||
required: true
|
||||
language: !<!Languages>
|
||||
|
@ -1993,8 +2026,8 @@ operationGroups:
|
|||
protocol: !<!Protocols>
|
||||
http: !<!HttpParameter>
|
||||
in: header
|
||||
- !<!Parameter> &ref_108
|
||||
schema: *ref_107
|
||||
- !<!Parameter> &ref_109
|
||||
schema: *ref_108
|
||||
implementation: Method
|
||||
required: true
|
||||
language: !<!Languages>
|
||||
|
@ -2006,7 +2039,7 @@ operationGroups:
|
|||
in: body
|
||||
style: json
|
||||
signatureParameters:
|
||||
- *ref_108
|
||||
- *ref_109
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: ''
|
||||
|
@ -2020,13 +2053,13 @@ operationGroups:
|
|||
- application/json
|
||||
uri: '{$host}'
|
||||
signatureParameters:
|
||||
- *ref_109
|
||||
- *ref_110
|
||||
- *ref_111
|
||||
- *ref_112
|
||||
- *ref_113
|
||||
responses:
|
||||
- !<!SchemaResponse>
|
||||
schema: *ref_107
|
||||
schema: *ref_108
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: ''
|
||||
|
|
|
@ -530,6 +530,11 @@ namespace NameConflicts.Models
|
|||
writer.WritePropertyName("yield");
|
||||
writer.WriteStringValue(Yield);
|
||||
}
|
||||
if (System != null)
|
||||
{
|
||||
writer.WritePropertyName("System");
|
||||
writer.WriteStringValue(System.Value.ToString());
|
||||
}
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
|
@ -638,6 +643,7 @@ namespace NameConflicts.Models
|
|||
string @where = default;
|
||||
string @while = default;
|
||||
string @yield = default;
|
||||
SystemEnum? system = default;
|
||||
foreach (var property in element.EnumerateObject())
|
||||
{
|
||||
if (property.NameEquals("abstract"))
|
||||
|
@ -1567,8 +1573,17 @@ namespace NameConflicts.Models
|
|||
@yield = property.Value.GetString();
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("System"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
system = new SystemEnum(property.Value.GetString());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return new Class(@abstract, @add, @alias, @as, @ascending, @async, @await, @base, @bool, @break, @by, @byte, @catch, @char, @checked, @const, @continue, @decimal, @default, @delegate, @descending, @do, @double, @dynamic, @else, @enum, @event, @explicit, @extern, @false, @finally, @fixed, @float, @for, @foreach, @from, @get, @global, @goto, group, @if, @implicit, @in, @int, @interface, @internal, @into, @is, @join, @let, @lock, @long, @nameof, @namespace, @new, @null, @object, @on, @operator, orderby, @out, @override, @params, @partial, @private, @protected, @public, @readonly, @ref, @remove, @return, @sbyte, @sealed, select, @set, @short, @sizeof, @stackalloc, @static, @string, @struct, @switch, @this, @throw, @true, @try, @typeof, @uint, @ulong, @unchecked, @unmanaged, @unsafe, @ushort, @using, value, @var, @virtual, @void, @volatile, @when, @where, @while, @yield);
|
||||
return new Class(@abstract, @add, @alias, @as, @ascending, @async, @await, @base, @bool, @break, @by, @byte, @catch, @char, @checked, @const, @continue, @decimal, @default, @delegate, @descending, @do, @double, @dynamic, @else, @enum, @event, @explicit, @extern, @false, @finally, @fixed, @float, @for, @foreach, @from, @get, @global, @goto, group, @if, @implicit, @in, @int, @interface, @internal, @into, @is, @join, @let, @lock, @long, @nameof, @namespace, @new, @null, @object, @on, @operator, orderby, @out, @override, @params, @partial, @private, @protected, @public, @readonly, @ref, @remove, @return, @sbyte, @sealed, select, @set, @short, @sizeof, @stackalloc, @static, @string, @struct, @switch, @this, @throw, @true, @try, @typeof, @uint, @ulong, @unchecked, @unmanaged, @unsafe, @ushort, @using, value, @var, @virtual, @void, @volatile, @when, @where, @while, @yield, system);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,7 +119,8 @@ namespace NameConflicts.Models
|
|||
/// <param name="where"> . </param>
|
||||
/// <param name="while"> . </param>
|
||||
/// <param name="yield"> . </param>
|
||||
internal Class(string @abstract, string @add, string @alias, string @as, string @ascending, string @async, string @await, string @base, string @bool, string @break, string @by, string @byte, string @catch, string @char, string @checked, string @const, string @continue, string @decimal, string @default, string @delegate, string @descending, string @do, string @double, string @dynamic, string @else, string @enum, string @event, string @explicit, string @extern, string @false, string @finally, string @fixed, string @float, string @for, string @foreach, string @from, string @get, string @global, string @goto, string group, string @if, string @implicit, string @in, string @int, string @interface, string @internal, string @into, string @is, string @join, string @let, string @lock, string @long, string @nameof, string @namespace, string @new, string nullProperty, string @object, string @on, string @operator, string orderby, string @out, string @override, string @params, string @partial, string @private, string @protected, string @public, string @readonly, string @ref, string @remove, string @return, string @sbyte, string @sealed, string select, string @set, string @short, string @sizeof, string @stackalloc, string @static, string @string, string @struct, string @switch, string @this, string @throw, string @true, string @try, string @typeof, string @uint, string @ulong, string @unchecked, string @unmanaged, string @unsafe, string @ushort, string @using, string value, string @var, string @virtual, string @void, string @volatile, string @when, string @where, string @while, string @yield)
|
||||
/// <param name="system"> . </param>
|
||||
internal Class(string @abstract, string @add, string @alias, string @as, string @ascending, string @async, string @await, string @base, string @bool, string @break, string @by, string @byte, string @catch, string @char, string @checked, string @const, string @continue, string @decimal, string @default, string @delegate, string @descending, string @do, string @double, string @dynamic, string @else, string @enum, string @event, string @explicit, string @extern, string @false, string @finally, string @fixed, string @float, string @for, string @foreach, string @from, string @get, string @global, string @goto, string group, string @if, string @implicit, string @in, string @int, string @interface, string @internal, string @into, string @is, string @join, string @let, string @lock, string @long, string @nameof, string @namespace, string @new, string nullProperty, string @object, string @on, string @operator, string orderby, string @out, string @override, string @params, string @partial, string @private, string @protected, string @public, string @readonly, string @ref, string @remove, string @return, string @sbyte, string @sealed, string select, string @set, string @short, string @sizeof, string @stackalloc, string @static, string @string, string @struct, string @switch, string @this, string @throw, string @true, string @try, string @typeof, string @uint, string @ulong, string @unchecked, string @unmanaged, string @unsafe, string @ushort, string @using, string value, string @var, string @virtual, string @void, string @volatile, string @when, string @where, string @while, string @yield, SystemEnum? system)
|
||||
{
|
||||
Abstract = @abstract;
|
||||
Add = @add;
|
||||
|
@ -224,6 +225,7 @@ namespace NameConflicts.Models
|
|||
Where = @where;
|
||||
While = @while;
|
||||
Yield = @yield;
|
||||
System = system;
|
||||
}
|
||||
|
||||
public string Abstract { get; set; }
|
||||
|
@ -329,5 +331,6 @@ namespace NameConflicts.Models
|
|||
public string Where { get; set; }
|
||||
public string While { get; set; }
|
||||
public string Yield { get; set; }
|
||||
public SystemEnum? System { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace NameConflicts.Models
|
||||
{
|
||||
/// <summary> The SystemEnum. </summary>
|
||||
public readonly partial struct SystemEnum : IEquatable<SystemEnum>
|
||||
{
|
||||
private readonly string _value;
|
||||
|
||||
/// <summary> Determines if two <see cref="SystemEnum"/> values are the same. </summary>
|
||||
public SystemEnum(string value)
|
||||
{
|
||||
_value = value ?? throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
private const string SystemValue = "System";
|
||||
private const string SystemTextJsonValue = "System.Text.Json";
|
||||
|
||||
/// <summary> System. </summary>
|
||||
public static SystemEnum System { get; } = new SystemEnum(SystemValue);
|
||||
/// <summary> System.Text.Json. </summary>
|
||||
public static SystemEnum SystemTextJson { get; } = new SystemEnum(SystemTextJsonValue);
|
||||
/// <summary> Determines if two <see cref="SystemEnum"/> values are the same. </summary>
|
||||
public static bool operator ==(SystemEnum left, SystemEnum right) => left.Equals(right);
|
||||
/// <summary> Determines if two <see cref="SystemEnum"/> values are not the same. </summary>
|
||||
public static bool operator !=(SystemEnum left, SystemEnum right) => !left.Equals(right);
|
||||
/// <summary> Converts a string to a <see cref="SystemEnum"/>. </summary>
|
||||
public static implicit operator SystemEnum(string value) => new SystemEnum(value);
|
||||
|
||||
/// <inheritdoc />
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public override bool Equals(object obj) => obj is SystemEnum other && Equals(other);
|
||||
/// <inheritdoc />
|
||||
public bool Equals(SystemEnum other) => string.Equals(_value, other._value, StringComparison.Ordinal);
|
||||
|
||||
/// <inheritdoc />
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public override int GetHashCode() => _value?.GetHashCode() ?? 0;
|
||||
/// <inheritdoc />
|
||||
public override string ToString() => _value;
|
||||
}
|
||||
}
|
|
@ -170,7 +170,18 @@
|
|||
"when": { "type": "string" },
|
||||
"where": { "type": "string" },
|
||||
"while": { "type": "string" },
|
||||
"yield": { "type": "string" }
|
||||
"yield": { "type": "string" },
|
||||
"System": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"System",
|
||||
"System.Text.Json"
|
||||
],
|
||||
"x-ms-enum": {
|
||||
"name": "SystemEnum",
|
||||
"modelAsString": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче