protected virtual string ResolveFullQualifiedTypeName(RosTypeInfo type, bool useInterface) { string typeString; if (type.IsBuiltInType) { var typeMapper = BuiltInTypeMapping.Create(type); typeString = typeMapper.Type.ToString(); } else { var rosPackageName = type.PackageName ?? _packageName; var rosTypeName = type.TypeName; typeString = ResolveFullQualifiedTypeName(rosPackageName, rosTypeName); } if (type.IsArray) { if (useInterface) { typeString = $"System.Collections.Generic.IList<{typeString}>"; } else { typeString = $"System.Collections.Generic.List<{typeString}>"; } } return(typeString); }
public static bool IsType(this RosTypeInfo rosType, Type expectedType) { if (rosType.IsArray || !rosType.IsBuiltInType) { return(false); } try { var typeMapper = BuiltInTypeMapping.Create(rosType); return(typeMapper.Type == expectedType); } catch (NotSupportedException) { return(false); } }
public void Can_parse_simple_message() { var message = "int8 fooo"; var actual = new RobSharper.Ros.MessageParser.MessageParser(message).Parse();; Assert.NotNull(actual); Assert.Empty(actual.Comments); Assert.Empty(actual.Constants); Assert.Single(actual.Fields); var field = actual.Fields.First(); var typeMapping = BuiltInTypeMapping.Create(field.TypeInfo); Assert.Equal(BuiltInTypeMapping.Int8, typeMapping); Assert.Equal("fooo", field.Identifier); }
public static bool IsValueType(this RosTypeInfo type) { if (type.IsArray || !type.IsBuiltInType) { return(false); } try { var typeMapper = BuiltInTypeMapping.Create(type); return(typeMapper.Type.IsValueType); } catch (NotSupportedException) { return(false); } }
public static bool SupportsEqualityComparer(this RosTypeInfo type) { if (type.IsArray || !type.IsBuiltInType) { return(false); } try { var typeMapper = BuiltInTypeMapping.Create(type); return(typeMapper.Type == typeof(string) || (typeMapper.Type != typeof(double) && typeMapper.Type != typeof(float))); } catch (NotSupportedException) { return(false); } }