예제 #1
0
 public PEModuleInfo(IDataReader dataReader, ulong imageBase, string fileName, bool isVirtual, int timestamp, int filesize, Version?version = null)
     : this(dataReader, imageBase, fileName, isVirtual)
 {
     _timestamp = timestamp;
     _filesize  = filesize;
     _version   = version;
 }
예제 #2
0
 public bool Equals(Version?other)
 {
     return(other is object &&
            Major == other.Major &&
            Minor == other.Minor &&
            Patch == other.Build);
 }
예제 #3
0
        public static HttpResponseMessage CreateHeadersOnlyResponse(
            HttpStatusCode statusCode,
            StatusCode grpcStatusCode,
            string?grpcEncoding        = null,
            Version?version            = null,
            string?retryPushbackHeader = null,
            IDictionary <string, string>?customHeaders = null)
        {
            var message = new HttpResponseMessage(statusCode)
            {
                Version = version ?? ProtocolVersion
            };

            message.RequestMessage = new HttpRequestMessage();
#if NET472
            message.RequestMessage.Properties[TrailingHeadersHelpers.ResponseTrailersKey] = new ResponseTrailers();
#endif
            message.Headers.Add(MessageEncodingHeader, grpcEncoding ?? IdentityGrpcEncoding);
            if (retryPushbackHeader != null)
            {
                message.Headers.Add("grpc-retry-pushback-ms", retryPushbackHeader);
            }

            if (customHeaders != null)
            {
                foreach (var customHeader in customHeaders)
                {
                    message.Headers.Add(customHeader.Key, customHeader.Value);
                }
            }

            message.Headers.Add(StatusTrailer, grpcStatusCode.ToString("D"));

            return(message);
        }
예제 #4
0
        static FrameworkKind GetFrameworkKind_Directory(string directory, out Version?version)
        {
            if (File.Exists(Path.Combine(directory, UnityEngineFilename)))
            {
                version = null;
                return(FrameworkKind.Unity);
            }
            if (File.Exists(Path.Combine(directory, SelfContainedDotNetFilename)))
            {
                version = null;
                return(FrameworkKind.SelfContainedDotNet);
            }

            // Could be a runtime sub dir, eg. "<basedir>\runtimes\unix\lib\netcoreapp2.0". These assemblies
            // don't always have a TFM attribute.
            // Could also be the compilation output directory.
            var dirName = Path.GetFileName(directory);

            if (TryParseVersion("netcoreapp", dirName, out var fwkVersion))
            {
                version = fwkVersion;
                return(FrameworkKind.DotNet);
            }
            else if (TryParseNetFrameworkVersion("net", dirName, out fwkVersion))
            {
                version = fwkVersion;
                return(version.Major < 4 ? FrameworkKind.DotNetFramework2 : FrameworkKind.DotNetFramework4);
            }

            version = null;
            return(FrameworkKind.Unknown);
        }
예제 #5
0
        public AssemblyName(string assemblyName)
            : this()
        {
            if (assemblyName == null)
            {
                throw new ArgumentNullException(nameof(assemblyName));
            }
            if ((assemblyName.Length == 0) ||
                (assemblyName[0] == '\0'))
            {
                throw new ArgumentException(SR.Format_StringZeroLength);
            }

            AssemblyNameParser.AssemblyNameParts parts = AssemblyNameParser.Parse(assemblyName);
            _name    = parts._name;
            _version = parts._version;
            _flags   = parts._flags;
            if ((parts._flags & AssemblyNameFlags.PublicKey) != 0)
            {
                _publicKey = parts._publicKeyOrToken;
            }
            else
            {
                _publicKeyToken = parts._publicKeyOrToken;
            }

            if (parts._cultureName != null)
            {
                _cultureInfo = new CultureInfo(parts._cultureName);
            }
        }
예제 #6
0
        // constructor used by metadata reader:
        internal AssemblyIdentity(
            bool noThrow,
            string name,
            Version?version    = null,
            string?cultureName = null,
            ImmutableArray <byte> publicKeyOrToken = default,
            bool hasPublicKey               = false,
            bool isRetargetable             = false,
            AssemblyContentType contentType = AssemblyContentType.Default
            )
        {
            Debug.Assert(name != null);
            Debug.Assert(
                (hasPublicKey && MetadataHelpers.IsValidPublicKey(publicKeyOrToken)) ||
                (
                    !hasPublicKey &&
                    (
                        publicKeyOrToken.IsDefaultOrEmpty ||
                        publicKeyOrToken.Length == PublicKeyTokenSize
                    )
                )
                );
            Debug.Assert(noThrow);

            _name           = name;
            _version        = version ?? NullVersion;
            _cultureName    = NormalizeCultureName(cultureName);
            _contentType    = IsValid(contentType) ? contentType : AssemblyContentType.Default;
            _isRetargetable = isRetargetable && _contentType != AssemblyContentType.WindowsRuntime;
            InitializeKey(publicKeyOrToken, hasPublicKey, out _publicKey, out _lazyPublicKeyToken);
        }
        private bool TryGetLatestReleaseTrackingLineCore(
            string ruleId,
            Version?maxVersion,
            [NotNullWhen(returnValue: true)] out Version?version,
            [NotNullWhen(returnValue: true)] out ReleaseTrackingLine?releaseTrackingLine)
        {
            version             = null;
            releaseTrackingLine = null;
            if (!ReleaseTrackingDataByRuleIdMap.TryGetValue(ruleId, out var releaseTrackingDataForRule) ||
                releaseTrackingDataForRule.ReleasesByVersionMap.IsEmpty)
            {
                return(false);
            }

            foreach (var(releaseVersion, releaseLine) in releaseTrackingDataForRule.ReleasesByVersionMap)
            {
                if (maxVersion == null || releaseVersion <= maxVersion)
                {
                    version             = releaseVersion;
                    releaseTrackingLine = releaseLine;
                    return(true);
                }
            }

            return(false);
        }
예제 #8
0
        public static string Format(string?name, Version?version, string?culture, byte[]?publicKeyOrToken, DmdAssemblyNameFlags attributes, bool isPublicKeyToken)
        {
            StringBuilder?sb = ObjectPools.AllocStringBuilder();

            Format(sb, name, version, culture, publicKeyOrToken, attributes, isPublicKeyToken);
            return(ObjectPools.FreeAndToString(ref sb));
        }
예제 #9
0
        public static bool VerifyAssemblyVersions()
        {
            Version?ttgVersion    = Assembly.GetAssembly(typeof(TabbedTortoiseGit.TTG))?.GetName().Version;
            Version?tabsVersion   = Assembly.GetAssembly(typeof(Tabs.TabControl))?.GetName().Version;
            Version?commonVersion = Assembly.GetAssembly(typeof(Common.Util))?.GetName().Version;

            if (ttgVersion != null &&
                ttgVersion == tabsVersion &&
                ttgVersion == commonVersion)
            {
                return(true);
            }

            String?ttg    = ttgVersion?.ToString(3);
            String?tabs   = tabsVersion?.ToString(3);
            String?common = commonVersion?.ToString(3);

            LOG.Fatal($"Assembly version mismatch - TTG: {ttg} - Tabs: {tabs} - Common: {common}");

            String versionMismatchMessage = ($"The current assembly versions do not match:\n" +
                                             $"    Tabbed TortoiseGit: {ttg}\n" +
                                             $"    Tabs: {tabs}\n" +
                                             $"    Common: {common}\n\n" +
                                             $"Update Tagged TortoiseGit to resolve issue.\n" +
                                             $"If issue persists, uninstall and re-install Tabbed TortoiseGit.");

            MessageBox.Show(versionMismatchMessage, "Assembly Version Mismatch", MessageBoxButtons.OK, MessageBoxIcon.Error);
            return(false);
        }
        private EmulatorStatus Run(EmulatorAction action)
        {
            var status = new EmulatorStatus(this, action);

            if (!ReferenceEquals(status.Version, null))
            {
                Version = status.Version;
            }

            if (!ReferenceEquals(status.BlobEndpoint, null))
            {
                BlobEndpoint = status.BlobEndpoint;
            }

            if (!ReferenceEquals(status.QueueEndpoint, null))
            {
                QueueEndpoint = status.QueueEndpoint;
            }

            if (!ReferenceEquals(status.TableEndpoint, null))
            {
                TableEndpoint = status.TableEndpoint;
            }

            return(status);
        }
        internal static int GetVersionHeight(LibGit2Context context, Version?baseVersion = null)
        {
            if (context.Commit is null)
            {
                return(0);
            }

            var tracker = new GitWalkTracker(context);

            var versionOptions = tracker.GetVersion(context.Commit);

            if (versionOptions is null)
            {
                return(0);
            }

            var baseSemVer =
                baseVersion is not null?SemanticVersion.Parse(baseVersion.ToString()) :
                    versionOptions.Version ?? SemVer0;

            var versionHeightPosition = versionOptions.VersionHeightPosition;

            if (versionHeightPosition.HasValue)
            {
                int height = GetHeight(context, c => CommitMatchesVersion(c, baseSemVer, versionHeightPosition.Value, tracker));
                return(height);
            }

            return(0);
        }
 /// <summary>
 /// Creates a new instance of <see cref="NpgsqlValueGenerationStrategyConvention" />.
 /// </summary>
 /// <param name="dependencies">Parameter object containing dependencies for this convention.</param>
 /// <param name="postgresVersion">The PostgreSQL version being targeted. This affects the default value generation strategy.</param>
 public NpgsqlValueGenerationStrategyConvention(
     ProviderConventionSetBuilderDependencies dependencies,
     Version?postgresVersion)
 {
     Dependencies     = dependencies;
     _postgresVersion = postgresVersion;
 }
예제 #13
0
        /// <summary>
        /// Gets the assembly's version.
        /// </summary>
        /// <param name="assembly">The assembly to get the version from</param>
        /// <returns>The assembly version</returns>
        public static Version?GetVersion(Assembly assembly)
        {
            Conditions.RequireReference(assembly, nameof(assembly));
            Version?result = assembly.GetName(false).Version;

            return(result);
        }
예제 #14
0
        public static bool TryParse(string str, [NotNullWhen(true)] out Version?version)
        {
            var match = _versionRegex.Match(str);

            if (match.Success)
            {
                version = new Version(
                    int.Parse(match.Groups[1].Value),
                    int.Parse(match.Groups[2].Value),
                    long.Parse(match.Groups[3].Value));
                return(true);
            }
            match = _preReleaseVersionRegex.Match(str);
            if (match.Success)
            {
                version = new Version(
                    int.Parse(match.Groups[1].Value),
                    int.Parse(match.Groups[2].Value),
                    long.Parse(match.Groups[4].Value),
                    match.Groups[3].Value);
                return(true);
            }
            version = null;
            return(false);
        }
 public MacOSUpdater(Version?currentVersion, string binDirectory, string appDataDirectory, string rollBackDirectory)
     : base(currentVersion,
            binDirectory,
            appDataDirectory,
            rollBackDirectory)
 {
 }
예제 #16
0
    /// <summary>
    /// Get version from the specified stream, Version property, or default (0.0.0.0)
    /// </summary>
    /// <param name="stream">Stream containing version file</param>
    /// <param name="version">Version object</param>
    internal static async Task <string> GetVersion(Stream?stream, Version?version)
    {
        // Attempt to read from stream
        if (stream is Stream s)
        {
            try
            {
                using var reader = new StreamReader(s);
                return(await reader.ReadToEndAsync().ConfigureAwait(false));
            }
            catch
            {
                // do nothing - the function will continue to try other methods
            }
        }

        // Attempt to read from version
        if (version is not null)
        {
            return(GetVersionString(version));
        }

        // Retun an empty version (0.0.0.0)
        return(GetVersionString(new(0, 0, 0, 0)));
    }
            public ResolvedReference(string resolvedPath, Version?version)
            {
                Assumes.NotNull(resolvedPath);

                ResolvedPath = resolvedPath;
                Version      = version;
            }
예제 #18
0
    public static async Task <LegalDocuments?> LoadAgreedAsync(string folderPath)
    {
        if (!Directory.Exists(folderPath))
        {
            return(null);
        }

        var legalDocCandidates = FindCandidates(folderPath);

        switch (legalDocCandidates.Count())
        {
        case 1:
            string?filePath = legalDocCandidates.Single();
            string?content  = await File.ReadAllTextAsync(filePath).ConfigureAwait(false);

            string? verString = Path.GetFileNameWithoutExtension(filePath);
            Version?version   = Version.Parse(verString);
            if (version is null)
            {
                throw new InvalidOperationException("Legal documents version is null.");
            }
            return(new LegalDocuments(version, content));

        case > 1:
            RemoveCandidates(folderPath);
            break;
        }

        return(null);
    }
예제 #19
0
 public NpgsqlNewGuidTranslator(
     ISqlExpressionFactory sqlExpressionFactory,
     Version?postgresVersion)
 {
     _sqlExpressionFactory   = sqlExpressionFactory;
     _uuidGenerationFunction = postgresVersion?.AtLeast(13) == true ? "gen_random_uuid" : "uuid_generate_v4";
 }
예제 #20
0
        public static bool IsGreaterThanOrEqualTo(this Version?current, Version?compare)
        {
            if (current == null)
            {
                return(compare == null);
            }

            if (compare == null)
            {
                return(true);
            }

            if (current.Major != compare.Major)
            {
                return(current.Major > compare.Major);
            }

            if (current.Minor != compare.Minor)
            {
                return(current.Minor > compare.Minor);
            }

            // For build or revision value of 0 equals to -1
            if (current.Build != compare.Build && (current.Build > 0 || compare.Build > 0))
            {
                return(current.Build > compare.Build);
            }

            if (current.Revision != compare.Revision && (current.Revision > 0 || compare.Revision > 0))
            {
                return(current.Revision > compare.Revision);
            }

            return(true);
        }
예제 #21
0
 static ProtoBlock[] RegisterNewBlock(string modNamespace, string shortID, Version?versionAdded, ProtoBlock substitute)
 {
     if (!versionAdded.HasValue)
     {
         versionAdded = Version.FirstVersion;
     }
     if (shortID.Contains("*"))
     {
         //Multicolored blocks
         ProtoBlock[] blocks = new ProtoBlock[Blocks.commonColors.Length];
         for (int i = 0; i < Blocks.commonColors.Length; i++)
         {
             string colorBlockID = shortID.Replace("*", Blocks.commonColors[i]);
             //TODO: how to substitute color block with another color block?
             var b = new ProtoBlock(modNamespace, colorBlockID, versionAdded.Value, substitute);
             BlockList.allBlocks.Add(b.ID, b);
             blocks[i] = b;
         }
         return(blocks);
     }
     else
     {
         var b = new ProtoBlock(modNamespace, shortID, versionAdded.Value, substitute);
         BlockList.allBlocks.Add(b.ID, b);
         return(new ProtoBlock[] { b });
     }
 }
 public OriginInfo(Uri origin, Version?version = null, long?size = null, ValidationContext?validationContext = null)
 {
     Origin            = origin ?? throw new ArgumentNullException(nameof(origin));
     Version           = version;
     Size              = size;
     ValidationContext = validationContext;
 }
예제 #23
0
        static bool TryParseNetFrameworkVersion(string prefix, string tfm, [NotNullWhen(true)] out Version?version)
        {
            if (!tfm.StartsWith(prefix))
            {
                version = null;
                return(false);
            }

            var verStr = tfm.Substring(prefix.Length);

            if (uint.TryParse(verStr, out uint ver))
            {
                if (ver <= 9)
                {
                    version = new Version((int)ver, 0, 0, 0);
                    return(true);
                }
                if (ver <= 99)
                {
                    version = new Version((int)(ver / 10), (int)(ver % 10), 0, 0);
                    return(true);
                }
                if (ver <= 999)
                {
                    version = new Version((int)(ver / 100), (int)((ver / 10) % 10), (int)(ver % 10), 0);
                    return(true);
                }
            }

            version = null;
            return(false);
        }
예제 #24
0
        bool IsUnavailable(ICustomAttributeProvider cap, out Version?version)
        {
            version = null;
            foreach (var a in cap.GetCustomAttributes(false))
            {
                var ca = a;
#if NET
                if (a is UnsupportedOSPlatformAttribute aa && aa.TryParse(out ApplePlatform? uaPlatform, out version))
                {
                    if (uaPlatform == Platform)
                    {
                        return(true);
                    }
                }
#else
                if (ca is UnavailableAttribute ua)
                {
                    if (ua.Platform == Platform)
                    {
                        return(true);
                    }
                }
#endif
            }
            return(false);
        }
예제 #25
0
            private bool ParseStatusLine()
            {
                if (_bodyOnly)
                {
                    _version = Version.Http1_1;
                    _status  = ResponseStatus.Ok;
                    NextStep();
                    return(false);
                }

                _continuation = false;
                var maybeLine = NextLine(false, "Response status line is required.");

                if (!maybeLine.IsPresent)
                {
                    return(true);
                }

                var line       = maybeLine.Get();
                var spaceIndex = line.IndexOf(' ');

                try
                {
                    _version = Version.From(line.Substring(0, spaceIndex).Trim());
                    _status  = line.Substring(spaceIndex + 1).Trim().ConvertToResponseStatus();

                    return(NextStep());
                }
                catch (Exception ex)
                {
                    throw new ArgumentException($"Response status line parsing exception:{ex.Message}", ex);
                }
            }
예제 #26
0
        AvailabilityBaseAttribute GetAvailable(ICustomAttributeProvider cap, out Version?version)
#endif
        {
            version = null;
            foreach (var a in cap.GetCustomAttributes(false))
            {
                var ca = a;
#if NET
                if (ca is SupportedOSPlatformAttribute aa && aa.TryParse(out ApplePlatform? platform, out version))
                {
                    if (platform == Platform)
                    {
                        return(aa);
                    }
                }
#else
                if (ca is AvailabilityBaseAttribute aa)
                {
                    if ((aa.AvailabilityKind != AvailabilityKind.Unavailable) && (aa.Platform == Platform))
                    {
                        return(aa);
                    }
                }
#endif
            }
            return(null);
        }
예제 #27
0
        [DynamicDependency(nameof(access))] // Automatically keeps all previous fields too due to StructLayout
        private AssemblyBuilder(AssemblyName n, AssemblyBuilderAccess access)
        {
            aname = (AssemblyName)n.Clone();

            if (!Enum.IsDefined(typeof(AssemblyBuilderAccess), access))
            {
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture,
                                                          "Argument value {0} is not valid.", (int)access),
                                            nameof(access));
            }

            name        = n.Name;
            this.access = (uint)access;

            /* Set defaults from n */
            if (n.CultureInfo != null)
            {
                culture = n.CultureInfo.Name;
            }
            Version?v = n.Version;

            if (v != null)
            {
                version = v.ToString();
            }
            public_key_token = n.GetPublicKeyToken();

            basic_init(this);

            // Netcore only allows one module per assembly
            manifest_module = new ModuleBuilder(this, "RefEmit_InMemoryManifestModule");
            modules         = new ModuleBuilder[] { manifest_module };
        }
예제 #28
0
            private bool ParseRequestLine()
            {
                _continuation = false;
                var maybeLine = NextLine(ResponseStatus.BadRequest.GetDescription(),
                                         "\n\nRequest line is required.");

                if (!maybeLine.IsPresent)
                {
                    return(true);
                }

                var line = maybeLine.Get();

                var parts = line.Split(' ');

                try
                {
                    _method  = Method.From(ParseSpecificRequestLinePart(parts, 1, "Method"));
                    _uri     = ParseSpecificRequestLinePart(parts, 2, "URI/path").ToMatchableUri();
                    _version = Version.From(ParseSpecificRequestLinePart(parts, 3, "HTTP/version"));

                    return(NextStep());
                }
                catch (Exception e)
                {
                    throw new ArgumentException(
                              $"{ResponseStatus.BadRequest.GetDescription()}\n\nParsing exception: {e.Message}", e);
                }
            }
예제 #29
0
        [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
        internal Assembly?InternalGetSatelliteAssembly(CultureInfo culture,
                                                       Version?version,
                                                       bool throwOnFileNotFound)
        {
            var an = new AssemblyName();

            an.SetPublicKey(GetPublicKey());
            an.Flags       = GetFlags() | AssemblyNameFlags.PublicKey;
            an.Version     = version ?? GetVersion();
            an.CultureInfo = culture;
            an.Name        = GetSimpleName() + ".resources";

            // This stack crawl mark is never used because the requesting assembly is explicitly specified,
            // so the value could be anything.
            StackCrawlMark  unused      = default;
            RuntimeAssembly?retAssembly = InternalLoad(an, this, ref unused, throwOnFileNotFound);

            if (retAssembly == this)
            {
                retAssembly = null;
            }

            if (retAssembly == null && throwOnFileNotFound)
            {
                throw new FileNotFoundException(SR.Format(culture, SR.IO_FileNotFound_FileName, an.Name));
            }

            return(retAssembly);
        }
예제 #30
0
        /// <summary>
        /// Gets the <see cref="Version"/> information for the currently executing <see cref="System.Reflection.Assembly"/>.
        /// </summary>
        /// <returns>A string of the <see cref="Version"/> in the format "<c>Major.Minor.Build</c>"</returns>
        static string GetVersionInformation()
        {
            Version? version = System.Reflection.Assembly.GetExecutingAssembly()?.GetName()?.Version;
            if (version == null) return "Version information not available.";

            return $"{version.Major}.{version.Minor}.{version.Build}";
        }