private Type GetType()

in src/Microsoft.TestPlatform.ObjectModel/TestProperty/TestProperty.cs [173:246]


    private Type GetType(string typeName)
    {
        ValidateArg.NotNull(typeName, nameof(typeName));

        Type type = null;

        try
        {
            // This only works for the type is in the currently executing assembly or in Mscorlib.dll.
            type = Type.GetType(typeName);

            if (type == null)
            {
                type = Type.GetType(typeName.Replace("Version=4.0.0.0", "Version=2.0.0.0")); // Try 2.0 version as discovery returns version of 4.0 for all cases
            }

            // For UAP the type namespace for System.Uri,System.TimeSpan and System.DateTimeOffset differs from the desktop version.
            if (type == null && typeName.StartsWith("System.Uri"))
            {
                type = typeof(Uri);
            }
            else if (type == null && typeName.StartsWith("System.TimeSpan"))
            {
                type = typeof(TimeSpan);
            }
            else if (type == null && typeName.StartsWith("System.DateTimeOffset"))
            {
                type = typeof(DateTimeOffset);
            }
            else if (type == null && typeName.StartsWith("System.Int16"))
            {
                // For LineNumber property - Int is required
                type = typeof(Int16);
            }
            else if (type == null && typeName.StartsWith("System.Int32"))
            {
                type = typeof(Int32);
            }
            else if (type == null && typeName.StartsWith("System.Int64"))
            {
                type = typeof(Int64);
            }
        }
        catch (Exception)
        {
#if FullCLR
            // Try to see if the typeName contains Windows Phone PKT in that case load it from
            // desktop side
            if (typeName.Contains(s_windowsPhonePKT))
            {
                type = GetType(typeName.Replace(s_windowsPhonePKT, s_visualStudioPKT));
            }

            if (type == null)
            {
                System.Diagnostics.Debug.Fail("The test property type " + typeName + " of property " + Id + "is not supported.");
#else
            System.Diagnostics.Debug.WriteLine("The test property type " + typeName + " of property " + Id + "is not supported.");
#endif
#if FullCLR
            }
#endif
        }
        finally
        {
            // default is of string type.
            if (type == null)
            {
                type = typeof(string);
            }
        }

        return type;
    }