Hi,
here are changes to
assembly:: and version:: functions. It was pretty straightforward so there
shoudnt be many bugs. Are there any backward-compatibility
issues?
I do not find any
test-cases to those functions so I test it in the independent .build script
(attached).
Those functions are
not changed (but are somehow connected with versions):
file::get-file-version still returns string (not
System.Version)
file::get-product-version the same
nant::get-version
returns string (not System.Version)
nant::get-clr-version the same
pkg-config::
functions return string not System.Version
should some of them
be changed?
BTW: at latest
nightly I found those problems:
- Core.csproj is
missing Types/Token.cs
- alot of obsolete
functions called in the ExpressionEvaluatorTest
- alot of obsolete
warning during core compilation (this is propably ok since we have to use
obsolete internal function for obsolete
attributes/tasks)Martin
// NAnt - A .NET build tool // Copyright (C) 2001-2004 Gerry Shaw // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // Gert Driesen ([EMAIL PROTECTED])
using System;
using NAnt.Core;
using NAnt.Core.Attributes;
namespace NAnt.Core.Functions {
[FunctionSet("version", "Version")]
public class VersionFunctions : FunctionSetBase {
#region Public Instance Constructors
public VersionFunctions(Project project, PropertyDictionary properties) :
base(project, properties) {
}
#endregion Public Instance Constructors
#region Public Static Methods
/// <summary>
/// Gets the value of the major component of a given version string.
/// </summary>
/// <param name="version">A string containing the major, minor, build, and
revision numbers, where each number is delimited with a period character ('.').</param>
/// <returns>
/// The major version number.
/// </returns>
[Function("get-major")]
public static int GetMajor(System.Version version) {
return version.Major;
}
/// <summary>
/// Gets the value of the minor component of a given version string.
/// </summary>
/// <param name="version">A string containing the major, minor, build, and
revision numbers, where each number is delimited with a period character ('.').</param>
/// <returns>
/// The minor version number.
/// </returns>
[Function("get-minor")]
public static int GetMinor(System.Version version) {
return version.Minor;
}
/// <summary>
/// Gets the value of the build component of a given version string.
/// </summary>
/// <param name="version">A string containing the major, minor, build, and
revision numbers, where each number is delimited with a period character ('.').</param>
/// <returns>
/// The build number, or -1 if the build number is undefined.
/// </returns>
[Function("get-build")]
public static int GetBuild(System.Version version) {
return version.Build;
}
/// <summary>
/// Gets the value of the revision component of a given version string.
/// </summary>
/// <param name="version">A string containing the major, minor, build, and
revision numbers, where each number is delimited with a period character ('.').</param>
/// <returns>
/// The revision number, or -1 if the revision number is undefined.
/// </returns>
[Function("get-revision")]
public static int GetRevision(System.Version version) {
return version.Revision;
}
/// <summary>
/// Converts the specified <see cref="System.Version" /> to its
equivalent string
/// representation.
/// </summary>
/// <param name="value">A <see cref="System.Version" /> to
convert.</param>
/// <returns>
/// The string representation of the values of the major, minor,
build, and revision components.
/// </returns>
[Function("to-string")]
public static string ToString(System.Version value)
{
return value.ToString();
}
#endregion Public Static Methods
}
}
// NAnt - A .NET build tool
// Copyright (C) 2001-2004 Gerry Shaw
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Ian Maclean ([EMAIL PROTECTED])
// Jaroslaw Kowalski ([EMAIL PROTECTED])
using System;
using System.IO;
using System.Collections;
using System.Reflection;
using System.Globalization;
using NAnt.Core;
using NAnt.Core.Types;
using NAnt.Core.Attributes;
namespace NAnt.Core.Functions {
/// <summary>
/// Functions to return information for a given assembly.
/// </summary>
[FunctionSet("assembly", "Assembly")]
public class AssemblyFunctions : FunctionSetBase {
#region Public Instance Constructors
public AssemblyFunctions(Project project, PropertyDictionary properties) :
base(project, properties) {}
#endregion Public Instance Constructors
#region Public Static Methods
/// <summary>
/// Gets the version of the given assembly.
/// </summary>
/// <param name="assemblyFile">The AssemblyName of the assembly to get version
info for.</param>
/// <returns>
/// The full version (System.Version) of the given assembly file.
/// </returns>
[Function("get-version")]
public static System.Version GetVersion(AssemblyName assemblyFile) {
return assemblyFile.Version;
}
/// <summary>
/// Gets the full name of the assembly, also known as the display name.
/// </summary>
/// <param name="assemblyFile">The AssemblyName of the assembly to get the
full name for.</param>
/// <returns>
/// The full name of the assembly, also known as the display name.
/// </returns>
[Function("get-full-name")]
public static string GetFullName(System.Reflection.AssemblyName assemblyFile) {
return assemblyFile.FullName;
}
/// <summary>
/// Gets the simple, unencrypted name of the assembly.
/// </summary>
/// <param name="assemblyFile">The AssemblyName of the assembly to get the
name for.</param>
/// <returns>
/// The simple, unencrypted name of the assembly.
/// </returns>
[Function("get-name")]
public static string GetName(AssemblyName assemblyFile) {
return assemblyFile.Name;
}
/// <summary>
/// Gets the culture supported by the assembly.
/// </summary>
/// <param name="assemblyFile">The AssemblyName of the assembly to get the
culture for.</param>
/// <returns>
/// Display name of the assembly's culture.
/// </returns>
[Function("get-culture")]
public static string GetCulture(AssemblyName assemblyFile) {
return assemblyFile.CultureInfo.DisplayName;
}
/// <summary>
/// Loads specified assembly file and returns its AssemblyName.
/// </summary>
/// <param name="assemblyFile">The file name of the assembly to
load.</param>
/// <returns>
/// AssemblyName of loaded assembly. This could be further used by
other functions.
/// </returns>
/// <exception cref="ArgumentException"><paramref name="assemblyFile"
/> is an empty <see cref="string" />.</exception>
/// <exception cref="FileNotFoundException"><paramref
name="assemblyFile" /> does not exist.</exception>
/// <exception cref="BadImageFormatException"><paramref
name="assemblyFile" /> is not a valid assembly.</exception>
[Function("loadfile")]
public static AssemblyName LoadAssemblyFile(string assemblyFile)
{
return AssemblyName.GetAssemblyName(assemblyFile);
}
/// <summary>
/// Gets AssemblyName from Assembly instance.
/// </summary>
/// <param name="assembly">The assembly.</param>
/// <returns>
/// AssemblyName of specified assembly. This could be further used by
other functions.
/// </returns>
[Function("get-name")]
public static AssemblyName LoadAssemblyFile(Assembly assembly)
{
return assembly.GetName();
}
#endregion Public Static Methods
}
}
t1.build
Description: Binary data
