public void Defensive() { var property = new CodeProperty { Name = "prop", }; Assert.False(property.IsOfKind((CodePropertyKind[])null)); Assert.False(property.IsOfKind(Array.Empty <CodePropertyKind>())); }
public void Defensive() { var root = CodeNamespace.InitRootNamespace(); var property = new CodeProperty(root) { Name = "prop", }; Assert.False(property.IsOfKind((CodePropertyKind[])null)); Assert.False(property.IsOfKind(new CodePropertyKind[] { })); }
public void IsOfKind() { var property = new CodeProperty { Name = "prop", }; Assert.False(property.IsOfKind(CodePropertyKind.BackingStore)); property.Kind = CodePropertyKind.RequestBuilder; Assert.True(property.IsOfKind(CodePropertyKind.RequestBuilder)); Assert.True(property.IsOfKind(CodePropertyKind.RequestBuilder, CodePropertyKind.BackingStore)); Assert.False(property.IsOfKind(CodePropertyKind.BackingStore)); }
public void IsOfKind() { var root = CodeNamespace.InitRootNamespace(); var property = new CodeProperty(root) { Name = "prop", }; Assert.False(property.IsOfKind(CodePropertyKind.BackingStore)); property.PropertyKind = CodePropertyKind.RequestBuilder; Assert.True(property.IsOfKind(CodePropertyKind.RequestBuilder)); Assert.True(property.IsOfKind(CodePropertyKind.RequestBuilder, CodePropertyKind.BackingStore)); Assert.False(property.IsOfKind(CodePropertyKind.BackingStore)); }
private string GetDocCommentReturnType(CodeMethod codeMethod, CodeProperty accessedProperty) { return(codeMethod.Kind switch { CodeMethodKind.Deserializer => "array<string, callable>", CodeMethodKind.Getter when accessedProperty.IsOfKind(CodePropertyKind.AdditionalData) => "array<string, mixed>", CodeMethodKind.Getter when accessedProperty.Type.IsArray || accessedProperty.Type.IsCollection => $"array<{conventions.TranslateType(accessedProperty.Type)}>", _ => conventions.GetTypeString(codeMethod.ReturnType, codeMethod) });