public static bool tryDeserializeName(ref string line, NameKind nameKind, out string name) { name = string.Empty; switch (nameKind) { case NameKind.EnumBracket: { if (!line.StartsWith(" [")) { return(false); } name = line.Substring(5, line.IndexOf(']') - 5); break; } case NameKind.StructElement: { line = line.TrimStart(); if (!line.StartsWith(".")) { return(false); } name = line.Substring(1, line.IndexOf(' ') - 1); break; } } line = line.Substring(line.IndexOf('=', name.Length + 2) + 2); if (line[^ 1] == ',')
/// <summary> /// Check if the given name is a reserved keyword. if yes, add appropriate error to the refschema /// </summary> private bool CheckForSystemNamespace(UsingElement refSchema, string name, NameKind nameKind) { Debug.Assert( _definingSchema.ProviderManifest != null, "Since we don't allow using elements in provider manifest, provider manifest can never be null"); // We need to check for system namespace if (EdmItemCollection.IsSystemNamespace(_definingSchema.ProviderManifest, name)) { if (nameKind == NameKind.Alias) { refSchema.AddError( ErrorCode.CannotUseSystemNamespaceAsAlias, EdmSchemaErrorSeverity.Error, Strings.CannotUseSystemNamespaceAsAlias(name)); } else { refSchema.AddError( ErrorCode.NeedNotUseSystemNamespaceInUsing, EdmSchemaErrorSeverity.Error, Strings.NeedNotUseSystemNamespaceInUsing(name)); } return(true); } return(false); }
public int IndexOf(NameKind kind) { for (int i = 0; i < kindCount; ++i) { if (kinds[i] == kind) { return(i); } } return(-1); }
public int IndexOf(NameKind kind) { for (int i = 0; i < kindCount; ++i) { if (kinds[i] == kind) { return i; } } return -1; }
/// <summary> /// Check if the given name is a reserved keyword. if yes, add appropriate error to the refschema /// </summary> /// <param name="refSchema"> </param> /// <param name="name"> </param> /// <param name="nameKind"> </param> /// <returns> </returns> private bool CheckForSystemNamespace(UsingElement refSchema, string name, NameKind nameKind) { Debug.Assert( _definingSchema.ProviderManifest != null, "Since we don't allow using elements in provider manifest, provider manifest can never be null"); // We need to check for system namespace if (EdmItemCollection.IsSystemNamespace(_definingSchema.ProviderManifest, name)) { if (nameKind == NameKind.Alias) { refSchema.AddError( ErrorCode.CannotUseSystemNamespaceAsAlias, EdmSchemaErrorSeverity.Error, Strings.CannotUseSystemNamespaceAsAlias(name)); } else { refSchema.AddError( ErrorCode.NeedNotUseSystemNamespaceInUsing, EdmSchemaErrorSeverity.Error, Strings.NeedNotUseSystemNamespaceInUsing(name)); } return true; } return false; }
public override QualifiedNameSyntax GetChildName <TChild>(ILocatedOpenApiElement <TChild> child, NameKind nameKind) { QualifiedNameSyntax?name = Parent?.GetChildName(Element, nameKind); INameFormatter formatter = Context.NameFormatterSelector.GetFormatter(nameKind); if (name == null) { // At the components root, use the parameters namespace. In this case, use the key on the components // dictionary and not the parameter name, since multiple component parameters may have the same name. return(QualifiedName( GetNamespace(), IdentifierName(formatter.Format(Element.Key)))); } return(name); }
public QualifiedNameSyntax?GetChildName <TChild>(ILocatedOpenApiElement <TChild> child, NameKind nameKind) where TChild : IOpenApiElement => Parent?.GetChildName(child, nameKind);
public override QualifiedNameSyntax?GetChildName <TChild>(ILocatedOpenApiElement <TChild> child, NameKind nameKind) => QualifiedName((NameSyntax)TypeInfo.Name, IdentifierName( Context.NameFormatterSelector.GetFormatter(nameKind).Format(child.Key + "-Model")));
public override QualifiedNameSyntax GetChildName <TChild>(ILocatedOpenApiElement <TChild> child, NameKind nameKind) { QualifiedNameSyntax?name = Parent?.GetChildName(Element, nameKind); INameFormatter formatter = Context.NameFormatterSelector.GetFormatter(nameKind); if (name == null) { // At the components root, use the responses namespace return(QualifiedName( GetNamespace(), IdentifierName(formatter.Format(Element.Key)))); } return(name); }
public override QualifiedNameSyntax?GetChildName <TChild>(ILocatedOpenApiElement <TChild> child, NameKind nameKind) => null;
public virtual QualifiedNameSyntax?GetChildName <TChild>(ILocatedOpenApiElement <TChild> child, NameKind nameKind) where TChild : IOpenApiElement => null;
public virtual INameFormatter GetFormatter(NameKind nameKind) => nameKind switch {
public INameFormatter GetFormatter(NameKind nameKind) => nameKind switch {
public UserName(string name, NameKind kind) { Name = name; Kind = kind; }
public override QualifiedNameSyntax GetChildName <TChild>(ILocatedOpenApiElement <TChild> child, NameKind nameKind) { QualifiedNameSyntax?name = Parent?.GetChildName(Element, nameKind); INameFormatter formatter = Context.NameFormatterSelector.GetFormatter(nameKind); if (name == null) { // At the components root, use the schema namespace return(QualifiedName( Context.NamespaceProvider.GetNamespace(Element), IdentifierName(formatter.Format(Element.Key + "-Item")))); } return(name.WithRight(IdentifierName( formatter.Format(name.Right.Identifier.ValueText + "-Item")))); }
public YardarmTypeInfo(TypeSyntax name, NameKind kind = NameKind.Class, bool isGenerated = true) { Name = name ?? throw new ArgumentNullException(nameof(name)); Kind = kind; IsGenerated = isGenerated; }