attributes

How to use the GCC attribute 'format'?

Hello, Here is a little piece of code: #include <stdio.h> #include <stdarg.h> void MyPrintf(char const* format, va_list args); void MyVariadicPrintf(char const* format, ...); void MyPrintf(char const* format, va_list args) { vprintf(format, args); } void MyVariadicPrintf(char const* format, ...) { va_list args; va_start(...

[AssemblyInitialize] and TestDriven.Net

Has anyone experienced any issues with using the mstest attribute [AssemblyInitialize] when running tests with TestDriven.Net? I've tried 2.14 RTM and 2.22 RTM and neither seem to work for me. When I execute the test, the assembly init method isn't being executed. It's like TD.Net doesn't recongize the attribute. Any tips/ideas/clues i...

Can I create my own attribute classes in PowerShell 2.0?

I was wondering whether you could create your own .NET Attribute classes for PowerShell and use them in scripts e.g. [DebugAttribute=true] function DoSomeThing() { "I don't run in Release mode" } ...

How does the MethodImplAttribute work in .NET?

I was investigating some framework code (the System.AppDomain.GetDynamicDir method) and this was all the assembler showed: [MethodImpl(MethodImplOptions.InternalCall)] private extern string GetDynamicDir(); What happens when this method is called? I don't mean this specific method, but methods with this attribute in general. ...

Supporting DataContracts in .Net 2.0 libraries

Is it possible to create a library that can be consumed from .Net 2.0 and also allows .Net 3.0+ consumers to benefit from DataContracts if they wish? I don't see any technical obstacle for this other than the library that contains the different DataContract related attributes is a .Net 3.0 library. Can these attributes be implemented ma...

Restrict custom attribute so that it can be applied only to Specifc types in C# ?

Hi, I have a custom attribute which is applied to class properties and the class itself. Now all the classes that must apply my custom attribute are derived from a single base class. How can I restrict my Custom Attribute so that it can be applied to only those classes, that must derive from my base class? How do I do this ? Thanks, ...

Reflecting on property to get attributes. How to do when they are defined elsewhere?

I have a class Bar like this: class Foo : IFoo { [Range(0,255)] public int? FooProp {get; set} } class Bar : IFoo { private Foo foo = new Foo(); public int? FooProp { get { return foo.FooProp; } set { foo.FooProp= value; } } } I need to find the attribute [Range(0,255)] reflecting ONLY on the property ...

Rails: Virtual attributes and form values

Hi. I have a Model Book with a virtual attribute for create a Editor from the Book form. The code looks like: class Book < ActiveRecord::Base has_many :book_under_tags has_many :tags, :through => :book_under_tags has_one :editorial has_many :written_by has_many :authors, :through => :written_by def editorial_string self...

Real world use of custom .NET attributes

What kind of things have you used custom .NET attributes for in the real world? I've read several articles about them, but I have never used custom attributes. I feel like I might be overlooking them when they could be useful. EDIT I am talking about attributes that you create, not ones that are already included in the framework. ...

Render a View dynamically with UI-related attributes defined in the business entity

I'm using System.ComponentModel.DataAnnotations to give codesmith (using reflection to parse the field-attributes on BE) UI-hints to build my views. But I find DataAnnotations is limited enough. I like something richest, building new custom attributes where one could have more settings to build also complex user interface. I'm too lazy t...

Can I apply an attribute to an inherited member?

Suppose I have the following (trivially simple) base class: public class Simple { public string Value { get; set; } } I now want to do the following: public class PathValue : Simple { [XmlAttribute("path")] public string Value { get; set; } } public class ObjectValue : Simple { [XmlAttribute("object")] public str...

How do I edit an interface builder object programmatically?

I created a label using Interface Builder, and now I want to set the background color of the label using code instead of IB's color picker. (I want to do this so that I can define the color using RGB and eventually change the colorspace for the label.) I'm in cocoa. How do I edit the attributes of an IB object using code? My code lo...

Fortran Compiler Terminology: Dummy Variables and Attributes

Can someone explain to me what sort of an abstraction in the parser / compiler a dummy variable or attribute corresponds to? PURE SUBROUTINE F(X, Y) IMPLICIT NONE REAL, INTENT(INOUT) :: X, Y, C C REAL :: A, B C REAL, SAVE :: C = 3.14E0 PARAMETER (C = 3.14E0, X = 32, Y = X) X = Y + 2 * ...

Is there a way I can enforce a method to follow certain method signature?

let's say I have public delegate DataSet AutoCompleteDelegate( string filter, long rowOffset); can I make the following class to enforce that method signature? (just a conjured up idea): public class MiddleTier { [Follow(AutoCompleteDelegate)] public DataSet Customer_AutoComplete(string filter, long rowOffset) { ...

Change DisplayName attribute for a property

I am looking for a way to change the value of the DisplayName attribute of a property at run-time. Is this even possible in Windows Forms? ...

give the ID as a custom attribute to checkbox in a grid for manual update

I like to update just the value of my checkbox in a asp grid. so i thought i bind the id to the checkbox ( but how?) and fire an update in code behind by clicking the checkbox. but how can I get the ID, and where I have to bind this id to get it in code behind in the event? Thanks ...

WatiN - Which resource contains Attribute [TestMethod] or [Test]?

I am just beginning WatiN and in a lot of blogs I see attributes like [TestMethod] or simply [Test] used. For Example: MSForge Blog Post etc. etc. but when I attempt: using System; using System.Collections.Generic; using System.Linq; using System.Text; using WatiN.Core; using WatiN.Core.UnitTests; using WatiN.Core.Constraints; usi...

Is there an Attribute I can use in my class to tell DataGridView not to create a column for it when bound to a List<MyClass>

I have a class like this: private class MyClass { [DisplayName("Foo/Bar")] public string FooBar { get; private set; } public string Baz { get; private set; } public bool Enabled; } When I create a List<MyClass> and assign it to the DataSource of a DataGridView, the grid shows me two columns, "Foo/Bar" and "Baz". This is ...

Why is GUID attribute needed in the first place?

What is the necessity for the GUID attribute? why don't just let the compiler handle this automatically?! ...

jQuery attr href, why isn't it working?

I thought the following line of code should work fine: $(".1").attr('href', '#Home'); Right? But why isn't it working when I integrate it with another jQuery script? $(window).bind("load", function() { $('.1').click(function() { $('.1').removeClass('tab1'); $('.2').removeClass('active2'); $('.3').removeClass('active3...