diff options
Diffstat (limited to 'src/binder/inc/assemblyversion.inl')
-rw-r--r-- | src/binder/inc/assemblyversion.inl | 134 |
1 files changed, 30 insertions, 104 deletions
diff --git a/src/binder/inc/assemblyversion.inl b/src/binder/inc/assemblyversion.inl index 795f8c1765..d093808a1a 100644 --- a/src/binder/inc/assemblyversion.inl +++ b/src/binder/inc/assemblyversion.inl @@ -25,6 +25,26 @@ AssemblyVersion::~AssemblyVersion() // Noting to do here } +BOOL AssemblyVersion::HasMajor() +{ + return m_dwMajor != Unspecified; +} + +BOOL AssemblyVersion::HasMinor() +{ + return m_dwMinor != Unspecified; +} + +BOOL AssemblyVersion::HasBuild() +{ + return m_dwBuild != Unspecified; +} + +BOOL AssemblyVersion::HasRevision() +{ + return m_dwRevision != Unspecified; +} + DWORD AssemblyVersion::GetMajor() { return m_dwMajor; @@ -48,22 +68,21 @@ DWORD AssemblyVersion::GetRevision() void AssemblyVersion::SetFeatureVersion(DWORD dwMajor, DWORD dwMinor) { - m_dwMajor = dwMajor; - m_dwMinor = dwMinor; + // BaseAssemblySpec and AssemblyName properties store uint16 components for the version. Version and AssemblyVersion store + // int32 or uint32. When the former are initialized from the latter, the components are truncated to uint16 size. When the + // latter are initialized from the former, they are zero-extended to int32 size. For uint16 components, the max value is + // used to indicate an unspecified component. For int32 components, -1 is used. Since we're treating the version as an + // assembly version here, map the uint16 unspecified value to the int32 size. + m_dwMajor = dwMajor == UnspecifiedShort ? Unspecified : dwMajor; + m_dwMinor = dwMinor == UnspecifiedShort ? Unspecified : dwMinor; } void AssemblyVersion::SetServiceVersion(DWORD dwBuild, DWORD dwRevision) { - m_dwBuild = dwBuild; - m_dwRevision = dwRevision; -} - -BOOL AssemblyVersion::SetVersion(LPCWSTR pwzVersionStr) -{ - SmallStackSString versionString(pwzVersionStr); - - return TextualIdentityParser::ParseVersion(versionString, this); + // See comment in SetFeatureVersion, the same applies here + m_dwBuild = dwBuild == UnspecifiedShort ? Unspecified : dwBuild; + m_dwRevision = dwRevision == UnspecifiedShort ? Unspecified : dwRevision; } void AssemblyVersion::SetVersion(AssemblyVersion *pAssemblyVersion) @@ -74,83 +93,6 @@ void AssemblyVersion::SetVersion(AssemblyVersion *pAssemblyVersion) m_dwRevision = pAssemblyVersion->GetRevision(); } -BOOL AssemblyVersion::IsLargerFeatureVersion(AssemblyVersion *pAssemblyVersion) -{ - BOOL result = FALSE; - - if (GetMajor() > pAssemblyVersion->GetMajor()) - { - result = TRUE; - } - else if ((GetMajor() == pAssemblyVersion->GetMajor()) && - (GetMinor() > pAssemblyVersion->GetMinor())) - { - result = TRUE; - } - - return result; -} - -BOOL AssemblyVersion::IsEqualFeatureVersion(AssemblyVersion *pAssemblyVersion) -{ - BOOL result = FALSE; - - if ((GetMajor() == pAssemblyVersion->GetMajor()) && - (GetMinor() == pAssemblyVersion->GetMinor())) - { - result = TRUE; - } - - return result; -} - -BOOL AssemblyVersion::IsSmallerFeatureVersion(AssemblyVersion *pAssemblyVersion) -{ - BOOL result = FALSE; - - if (GetMajor() < pAssemblyVersion->GetMajor()) - { - result = TRUE; - } - else if ((GetMajor() == pAssemblyVersion->GetMajor()) && - (GetMinor() < pAssemblyVersion->GetMinor())) - { - result = TRUE; - } - - return result; -} - -BOOL AssemblyVersion::IsEqualServiceVersion(AssemblyVersion *pAssemblyVersion) -{ - BOOL result = FALSE; - - if ((GetBuild() == pAssemblyVersion->GetBuild()) && - (GetRevision() == pAssemblyVersion->GetRevision())) - { - result = TRUE; - } - - return result; -} - -BOOL AssemblyVersion::IsLargerServiceVersion(AssemblyVersion *pAssemblyVersion) -{ - BOOL result = FALSE; - - if (GetBuild() > pAssemblyVersion->GetBuild()) - { - result = TRUE; - } - else if ((GetBuild() == pAssemblyVersion->GetBuild()) && - (GetRevision() > pAssemblyVersion->GetRevision())) - { - result = TRUE; - } - - return result; -} - BOOL AssemblyVersion::Equals(AssemblyVersion *pAssemblyVersion) { BOOL result = FALSE; @@ -164,20 +106,4 @@ BOOL AssemblyVersion::Equals(AssemblyVersion *pAssemblyVersion) return result; } -BOOL AssemblyVersion::IsSmallerOrEqual(AssemblyVersion *pAssemblyVersion) -{ - return (Equals(pAssemblyVersion) || - IsSmallerFeatureVersion(pAssemblyVersion) || - (IsEqualFeatureVersion(pAssemblyVersion) && - !IsLargerServiceVersion(pAssemblyVersion))); -} - -BOOL AssemblyVersion::IsLargerOrEqual(AssemblyVersion *pAssemblyVersion) -{ - return (Equals(pAssemblyVersion) || - IsLargerFeatureVersion(pAssemblyVersion) || - (IsEqualFeatureVersion(pAssemblyVersion) && - IsLargerServiceVersion(pAssemblyVersion))); -} - #endif |