public void Handler_ShouldReturnAssemblyInfo_IfAssemblyInformationThere() { // Arrange var productName = _fixture.Create<string>(); var productAttribute = new AssemblyProductAttribute(productName); _sut.Stub(x => x.GetAssemblyAttribute<AssemblyProductAttribute>(_currentAssembly)).Return(productAttribute); var fileVersion = _fixture.Create<string>(); var fileVersionAttribute = new AssemblyFileVersionAttribute(fileVersion); _sut.Stub(x => x.GetAssemblyAttribute<AssemblyFileVersionAttribute>(_currentAssembly)) .Return(fileVersionAttribute); var buildId = _fixture.Create<string>(); var asmInfoAttribute = new AssemblyInformationalVersionAttribute(buildId); _sut.Stub(x => x.GetAssemblyAttribute<AssemblyInformationalVersionAttribute>(_currentAssembly)) .Return(asmInfoAttribute); // Act dynamic answer = _sut.Handler(_question); // Assert Assert.IsNotInstanceOfType(answer, typeof (string)); Assert.AreEqual(productName, answer.Product); Assert.AreEqual(fileVersion, answer.ProductVersion); Assert.AreEqual(buildId, answer.BuildId); }
public void AFVTau(System.Runtime.Versioning.ResourceExposureAttribute Bhpjwb, System.Web.UI.WebControls.MailMessageEventHandler lcclVgz, System.ComponentModel.DesignOnlyAttribute LJoU, System.Security.Cryptography.X509Certificates.X509ChainPolicy JAthRKz) { System.Web.Configuration.ProfilePropertySettingsCollection YPN = new System.Web.Configuration.ProfilePropertySettingsCollection(); System.Web.UI.WebControls.CommandEventArgs coGHdY = new System.Web.UI.WebControls.CommandEventArgs("wyKJlYHiXhmuI", 939670288); System.Windows.Forms.TreeNodeConverter TQkITGk = new System.Windows.Forms.TreeNodeConverter(); System.CodeDom.CodeNamespaceImport AMuF = new System.CodeDom.CodeNamespaceImport(); System.Runtime.Remoting.Channels.TransportHeaders ZPhf = new System.Runtime.Remoting.Channels.TransportHeaders(); System.Web.Configuration.ProfileSettingsCollection bGxTyT = new System.Web.Configuration.ProfileSettingsCollection(); System.Web.UI.Triplet NKo = new System.Web.UI.Triplet(94201957, 204067286, 181795136); System.Web.UI.WebControls.CreateUserWizardStep YVz = new System.Web.UI.WebControls.CreateUserWizardStep(); System.Net.Configuration.HttpCachePolicyElement gvpb = new System.Net.Configuration.HttpCachePolicyElement(); System.Runtime.InteropServices.IDispatchImplAttribute JMUwahj = new System.Runtime.InteropServices.IDispatchImplAttribute(-658); System.Web.UI.WebControls.WebParts.ConnectionConsumerAttribute WvLbFF = new System.Web.UI.WebControls.WebParts.ConnectionConsumerAttribute("tibFWnWRwJiTRnijF"); System.Web.UI.WebControls.MenuItemCollection QjImiIB = new System.Web.UI.WebControls.MenuItemCollection(new System.Web.UI.WebControls.MenuItem()); System.ComponentModel.WarningException Edl = new System.ComponentModel.WarningException("hLJ", "RxUjFInvYnsN"); System.Web.UI.WebControls.CreateUserWizardStep tnLG = new System.Web.UI.WebControls.CreateUserWizardStep(); System.Threading.ThreadExceptionEventArgs oVqHzS = new System.Threading.ThreadExceptionEventArgs(new System.Exception()); System.Windows.Forms.ToolStripPanel ubWJjW = new System.Windows.Forms.ToolStripPanel(); System.Windows.Forms.CheckedListBox vQnk = new System.Windows.Forms.CheckedListBox(); System.Data.EvaluateException lZuPd = new System.Data.EvaluateException("VDiWDw"); System.Collections.Specialized.OrderedDictionary NrEiCx = new System.Collections.Specialized.OrderedDictionary(); System.Web.Configuration.ExpressionBuilderCollection rKe = new System.Web.Configuration.ExpressionBuilderCollection(); System.Security.VerificationException gjQbpO = new System.Security.VerificationException("HdwsMd", new System.Exception()); System.Web.UI.WebControls.GridView hKm = new System.Web.UI.WebControls.GridView(); System.Collections.Specialized.StringCollection xaB = new System.Collections.Specialized.StringCollection(); System.Runtime.InteropServices.PreserveSigAttribute eVvQ = new System.Runtime.InteropServices.PreserveSigAttribute(); System.IO.IODescriptionAttribute aNN = new System.IO.IODescriptionAttribute("VPjQMtDWfg"); System.ComponentModel.BooleanConverter FvgYn = new System.ComponentModel.BooleanConverter(); System.Web.UI.WebControls.DetailsViewInsertedEventArgs PwpT = new System.Web.UI.WebControls.DetailsViewInsertedEventArgs(1190630802, new System.Exception()); System.Windows.Forms.ImageList xRwZA = new System.Windows.Forms.ImageList(); System.Globalization.JapaneseCalendar afnDCPz = new System.Globalization.JapaneseCalendar(); System.Web.Configuration.PassportAuthentication MfCQkqL = new System.Web.Configuration.PassportAuthentication(); System.Runtime.Remoting.RemotingException naDyQF = new System.Runtime.Remoting.RemotingException(); System.MissingFieldException ubX = new System.MissingFieldException("wtnxbHmoATXw", new System.Exception()); System.Web.UI.HtmlControls.HtmlInputText VLBD = new System.Web.UI.HtmlControls.HtmlInputText("gXFG"); System.Runtime.Remoting.ActivatedServiceTypeEntry doa = new System.Runtime.Remoting.ActivatedServiceTypeEntry("CWPQ", "eKcxOFlcYMF"); System.MissingMethodException PSQBjgG = new System.MissingMethodException("BQoFN", new System.Exception()); System.Windows.Forms.FolderBrowserDialog nyTD = new System.Windows.Forms.FolderBrowserDialog(); System.Runtime.InteropServices.OutAttribute sBWytdq = new System.Runtime.InteropServices.OutAttribute(); System.Web.UI.WebControls.FormViewUpdateEventArgs wrFEU = new System.Web.UI.WebControls.FormViewUpdateEventArgs(614564652); System.ArgumentOutOfRangeException Tyfmqs = new System.ArgumentOutOfRangeException("XOLQzNCqfjKHnxfq", new System.Exception()); System.Web.UI.ControlBuilder ubZZw = new System.Web.UI.ControlBuilder(); System.Windows.Forms.FlowLayoutPanel huyOf = new System.Windows.Forms.FlowLayoutPanel(); System.Configuration.UserSettingsGroup VkIAhTM = new System.Configuration.UserSettingsGroup(); System.Security.Cryptography.MD5CryptoServiceProvider ixAZ = new System.Security.Cryptography.MD5CryptoServiceProvider(); System.Runtime.Remoting.Metadata.SoapParameterAttribute QHvwhq = new System.Runtime.Remoting.Metadata.SoapParameterAttribute(); System.Reflection.AssemblyInformationalVersionAttribute IGrOTW = new System.Reflection.AssemblyInformationalVersionAttribute("qdWByXvKzB"); System.Windows.Forms.SelectionRangeConverter rwbzo = new System.Windows.Forms.SelectionRangeConverter(); Microsoft.SqlServer.Server.SqlTriggerAttribute PsugLs = new Microsoft.SqlServer.Server.SqlTriggerAttribute(); System.Globalization.ThaiBuddhistCalendar iMwCC = new System.Globalization.ThaiBuddhistCalendar(); }
public AssemblyInformationalVersionAttributeTest () { //create a dynamic assembly with the required attribute //and check for the validity dynAsmName.Name = "TestAssembly"; dynAssembly = Thread.GetDomain ().DefineDynamicAssembly ( dynAsmName,AssemblyBuilderAccess.Run ); // Set the required Attribute of the assembly. Type attribute = typeof (AssemblyInformationalVersionAttribute); ConstructorInfo ctrInfo = attribute.GetConstructor ( new Type [] { typeof (string) } ); CustomAttributeBuilder attrBuilder = new CustomAttributeBuilder (ctrInfo, new object [1] { "2.0.0.0" }); dynAssembly.SetCustomAttribute (attrBuilder); object [] attributes = dynAssembly.GetCustomAttributes (true); attr = attributes [0] as AssemblyInformationalVersionAttribute; }
private string GetAssembly(Type type) { if (type.ToString() == "System.Reflection.AssemblyVersionAttribute") {//程序集版本号,要用这个方法获取,无法用下边的方法获取,原因不知 return(System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()); } object[] attributes = System.Reflection.Assembly.GetExecutingAssembly().GetCustomAttributes(type, false); if (attributes.Length > 0) { if (type.ToString() == "System.Reflection.AssemblyCompanyAttribute") { #region//公司 System.Reflection.AssemblyCompanyAttribute company = (System.Reflection.AssemblyCompanyAttribute)attributes[0]; if (company.Company != "") { return(company.Company); } #endregion } else if (type.ToString() == "System.Reflection.AssemblyCopyrightAttribute") { #region//版权 System.Reflection.AssemblyCopyrightAttribute company = (System.Reflection.AssemblyCopyrightAttribute)attributes[0]; if (company.Copyright != "") { return(company.Copyright); } #endregion } else if (type.ToString() == "System.Reflection.AssemblyTitleAttribute") { #region//标题 System.Reflection.AssemblyTitleAttribute company = (System.Reflection.AssemblyTitleAttribute)attributes[0]; if (company.Title != "") { return(company.Title); } #endregion } else if (type.ToString() == "System.Reflection.AssemblyDescriptionAttribute") { #region//备注 System.Reflection.AssemblyDescriptionAttribute company = (System.Reflection.AssemblyDescriptionAttribute)attributes[0]; if (company.Description != "") { return(company.Description); } #endregion } else if (type.ToString() == "System.Reflection.AssemblyProductAttribute") { #region//产品名称 System.Reflection.AssemblyProductAttribute company = (System.Reflection.AssemblyProductAttribute)attributes[0]; if (company.Product != "") { return(company.Product); } #endregion } else if (type.ToString() == "System.Reflection.AssemblyTrademarkAttribute") { #region//商标 System.Reflection.AssemblyTrademarkAttribute company = (System.Reflection.AssemblyTrademarkAttribute)attributes[0]; if (company.Trademark != "") { return(company.Trademark); } #endregion } else if (type.ToString() == "System.Reflection.AssemblyConfigurationAttribute") { #region//获取程序集配置信息,具体什么内容,不清楚 System.Reflection.AssemblyConfigurationAttribute company = (System.Reflection.AssemblyConfigurationAttribute)attributes[0]; if (company.Configuration != "") { return(company.Configuration); } #endregion } else if (type.ToString() == "System.Reflection.AssemblyCultureAttribute") { #region//获取属性化程序集支持的区域性,具体什么内容,不清楚 System.Reflection.AssemblyCultureAttribute company = (System.Reflection.AssemblyCultureAttribute)attributes[0]; if (company.Culture != "") { return(company.Culture); } #endregion } else if (type.ToString() == "System.Reflection.AssemblyVersionAttribute") { #region//程序集版本号 System.Reflection.AssemblyVersionAttribute company = (System.Reflection.AssemblyVersionAttribute)attributes[0]; if (company.Version != "") { return(company.Version); } #endregion } else if (type.ToString() == "System.Reflection.AssemblyFileVersionAttribute") { #region//文件版本号 System.Reflection.AssemblyFileVersionAttribute company = (System.Reflection.AssemblyFileVersionAttribute)attributes[0]; if (company.Version != "") { return(company.Version); } #endregion } else if (type.ToString() == "System.Reflection.AssemblyInformationalVersionAttribute") { #region//产品版本号 System.Reflection.AssemblyInformationalVersionAttribute company = (System.Reflection.AssemblyInformationalVersionAttribute)attributes[0]; if (company.InformationalVersion != "") { return(company.InformationalVersion); } #endregion } } //如果没有 属性,或者 属性为一个空字符串,则返回 .exe 的名称 return(System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetExecutingAssembly().CodeBase)); }
static int Main(string[] args) { Values values = new Values(0x4); ArgParser argParser = new ArgParser(); argParser.add(new Arg('s', "server", "server name", "the tfs server to connect to", null)); argParser.add(new tfsinterface.PathVersionArg("src", "path[,version]", "the source of the changesets")); argParser.add(new tfsinterface.VersionArg("from", "version[,version]", "the changeset range to look in.")); argParser.add(new FlagArg("name-only", "add the path of the files to the changeset info", false)); argParser.add(new FlagArg("name-status", "print the path and the change type in the changeset info", false)); argParser.add(new ArgInt('d', "distance", new string[] { "distance or number of merge queries to run.", "default=1", "e.g. distance=2", " source path=$/main/ version=12", " query #1 = $/main/ => decompose 12.", " 12 => $/development/group1/ version 10", " query #2 = $/development/group1/ => decompose 10.", " 10 => $/code_review/group1/ version 8", " process stops." }, 1)); argParser.add(new ArgInt('j', "threads", new string[] { "number of threads to run merge queries in", " defaults to 8.", " if set to 1, queries are done in order.", " e.g. ", "query changeset 12, query parents of changeset 12, starting at the first parent.", " query the first parent, <insert recursion>" }, 8)); argParser.add(new ArgInt('c', "count", new string[] { "max number history items to query", " defaults to 10.", " if a range isn't specified, ", "this will control how many history items that are decomposed.", }, 10)); List <int> unknownArgs; bool argError = false == argParser.parse_args(args, out unknownArgs); /* if we don't have any args, the user needs to fix that too. */ if (!argError && (unknownArgs.Count < 1)) { argError = true; } if (argError) { /* get the version of the megahistory library. */ Version version = null; Assembly asm = Assembly.GetAssembly(typeof(megahistorylib.MegaHistory)); version = asm.GetName().Version; /* ******************** */ string libVersion = null; object[] objs = asm.GetCustomAttributes(typeof(System.Reflection.AssemblyInformationalVersionAttribute), true); if (objs != null) { System.Reflection.AssemblyInformationalVersionAttribute attr = objs[0] as System.Reflection.AssemblyInformationalVersionAttribute; if (attr != null) { libVersion = string.Format("lib version git: {0}", attr.InformationalVersion); } } if (libVersion == null) { libVersion = string.Format("lib version {0}.{1}.{2}.{3} (sp{4}/{5})", version.Major, version.Minor, version.Build, version.Revision, version.MajorRevision, version.MinorRevision); } argParser.print_help("<target>[,<version>]", new string[] { libVersion, "target - the required path we're looking at", "version - an optional version of the target path", string.Empty, "queries tfs for the list of changesets which make up a merge", string.Empty, "eg: megahistory -s foo --src $/foo,45 --from 10,45 $/bar,43" } ); return(1); } if (unknownArgs.Count > 0) { /* anything not caught by the above items is considered a target path and changeset. */ tfsinterface.PathVersionArg.GetParts(args[unknownArgs[0]], out values.target, out values.targetVer); } values.server = (string)argParser.get_arg <Arg>('s'); { tfsinterface.PathVersionArg arg = argParser.get_arg <tfsinterface.PathVersionArg>("src"); if (arg.Data != null) { arg.get_parts(out values.srcPath, out values.srcVer); } } { tfsinterface.VersionArg arg = argParser.get_arg <tfsinterface.VersionArg>("from"); if (arg.Data != null) { arg.get_parts(out values.fromVer, out values.toVer); } } if ((bool)argParser.get_arg <FlagArg>("name-only")) { values.printWhat = HistoryViewer.Printwhat.NameOnly; } else if ((bool)argParser.get_arg <FlagArg>("name-status")) { values.printWhat = HistoryViewer.Printwhat.NameStatus; } { saastdlib.ArgInt arg = argParser.get_arg <saastdlib.ArgInt>('d'); values.maxDistance = arg; } values.threads = argParser.get_arg <saastdlib.ArgInt>('j'); values.count = argParser.get_arg <saastdlib.ArgInt>('c'); megahistorylib.MegaHistory megahistory = new megahistorylib.MegaHistory(values.server, values.maxDistance); megahistorylib.MegaHistory.THREAD_COUNT = values.threads; /* this won't do a single changeset decomposition...? */ megahistory.query(values.target, values.targetVer, values.count, values.fromVer, values.toVer, null); HistoryViewer visitor = new HistoryViewer(values.printWhat, megahistory.Results); visitor.print(Console.Out); return(0); }