(Type type, bool generateHat = true)
| 438 | } |
| 439 | |
| 440 | public static string ToWinRT(Type type, bool generateHat = true) |
| 441 | { |
| 442 | if (type == typeof(void)) |
| 443 | { |
| 444 | return "void"; |
| 445 | } |
| 446 | |
| 447 | string fullName = GetTypeFullName(type); |
| 448 | var sb = new StringBuilder(); |
| 449 | bool typeConverted = false; |
| 450 | |
| 451 | if (CSharpToCppClassMap.ContainsKey(fullName)) |
| 452 | { |
| 453 | sb.Append(CSharpToCppClassMap[fullName]); |
| 454 | typeConverted = true; |
| 455 | } |
| 456 | |
| 457 | if (!type.IsGenericType && !typeConverted && !type.IsArray) |
| 458 | { |
| 459 | if (type.IsPrimitive) |
| 460 | { |
| 461 | // in case this is a primitive type |
| 462 | return Converter.ToWinRT(type)[0]; |
| 463 | } |
| 464 | else |
| 465 | { |
| 466 | sb.Append(type.FullName); |
| 467 | } |
| 468 | } |
| 469 | else if (type.IsArray) |
| 470 | { |
| 471 | sb.Append("System.Array"); |
| 472 | sb.Append('<'); |
| 473 | sb.AppendFormat(ToWinRT(type.GetElementType())); |
| 474 | sb.Append('>'); |
| 475 | } |
| 476 | else if (type.IsGenericType) |
| 477 | { |
| 478 | if (!typeConverted) |
| 479 | { |
| 480 | sb.Append(type.Namespace); |
| 481 | sb.Append("."); |
| 482 | sb.Append(type.Name); |
| 483 | sb.Remove(sb.Length - 2, 2); |
| 484 | } |
| 485 | |
| 486 | sb.Append('<'); |
| 487 | |
| 488 | foreach (var arg in type.GenericTypeArguments) |
| 489 | { |
| 490 | var argString = ToWinRT(arg); |
| 491 | sb.AppendFormat("{0}, ", argString); |
| 492 | } |
| 493 | sb.Remove(sb.Length - 2, 2); |
| 494 | sb.Append('>'); |
| 495 | } |
| 496 | |
| 497 | if ((!type.IsValueType || RefTypesInCppValueInCS.Contains(fullName)) && generateHat) |
no test coverage detected