Esempio n. 1
0
        public static bool TryParse(this OSPlatformAttribute self, [NotNullWhen(true)] out string?platform, out Version?version)
        {
            if (self is null)
            {
                throw new ArgumentNullException(nameof(self));
            }

            return(TryParse(self.PlatformName, out platform, out version));
        }
Esempio n. 2
0
        public static bool TryParse(this OSPlatformAttribute self, [NotNullWhen(true)] out ApplePlatform?platform, out Version?version)
        {
            platform = null;

            if (!TryParse(self, out string?supportedPlatform, out version))
            {
                return(false);
            }

            return(TryGetApplePlatform(supportedPlatform, out platform));
        }
        public void TranslateMultipleOSPlatformAttributes()
        {
            var supported1  = new SupportedOSPlatformAttribute("Windows7.0");
            var supported2  = new SupportedOSPlatformAttribute("Linux");
            var osPlatforms = new OSPlatformAttribute[] { supported1, supported2 };

            object[] attributes = OSPlatformTranslator.Translate(osPlatforms).ToArray();
            Assert.That(attributes, Has.Length.EqualTo(1));
            Assert.That(attributes[0], Is.InstanceOf <PlatformAttribute>());
            var platform = (PlatformAttribute)attributes[0];

            Assert.That(platform.Include, Is.EqualTo("Windows7,Linux"), nameof(platform.Include));
            Assert.That(platform.Exclude, Is.Null, nameof(platform.Exclude));
        }
Esempio n. 4
0
        public static AvailabilityBaseAttribute Convert(this OSPlatformAttribute a)
        {
            if (a == null)
            {
                return(null);
            }

            PlatformName p;
            int          n = 0;

            switch (a.PlatformName)
            {
            case string dummy when a.PlatformName.StartsWith("ios"):
                p = PlatformName.iOS;

                n = "ios".Length;
                break;

            case string dummy when a.PlatformName.StartsWith("tvos"):
                p = PlatformName.TvOS;

                n = "tvos".Length;
                break;

            case string dummy when a.PlatformName.StartsWith("watchos"):
                p = PlatformName.WatchOS;

                n = "watchos".Length;
                break;

            case string dummy when a.PlatformName.StartsWith("macos"):
                p = PlatformName.MacOSX;

                n = "macos".Length;
                break;

            case string dummy when a.PlatformName.StartsWith("maccatalyst"):
                p = PlatformName.MacCatalyst;

                n = "maccatalyst".Length;
                break;

            default:
                return(null);
            }
            bool versioned = Version.TryParse(a.PlatformName [n..], out var v);
 void CheckIntroduced(Type t, OSPlatformAttribute ta, MemberInfo m)