Property binding vs attribute interpolation

Property binding like [trueValue]=”…” evaluates the expression “…” and assigns the value “true” evaluates to the value true “Y” is unknown. There is no internal Y value in TypeScript and no property in the component class instance, which is the scope of template binding. In this case you would want [trueValue]=”‘Y'” Note the additional quotes … Read more

Can C# Attributes access the Target Class?

There are cases where you can’t rely on the calling code to pass a type reference. Below is a solution I cooked up to solve this problem. It’s a bit of a shot-gun approach, but it does work… using System; using System.Reflection; using System.Collections.Generic; using System.Linq; using System.Diagnostics; namespace Ethica.Reflection { /// <summary> /// Helps … Read more

NUnit Test Run Order

I just want to point out that while most of the responders assumed these were unit tests, the question did not specify that they were. nUnit is a great tool that can be used for a variety of testing situations. I can see appropriate reasons for wanting to control test order. In those situations I … Read more

How do the In and Out attributes work in .NET?

This is a remarkably poorly documented feature of .NET Remoting. It doesn’t have anything to do with whether your class is [Serializable] or derived from MarshalByRefObject. At issue here is how the argument is marshaled across the AppDomain boundary. The call itself is made under the hood by Remoting. Arrays do not automatically get marshaled … Read more

Attribute on Interface members does not work

Attributes on interface properties doesn’t get inherited to the class, you may make your interface an Abstract Class. Found an answer from Microsoft: The product team does not want to implement this feature, for two main reasons: Consistency with DataAnnotations.Validator Consistency with validation behavior in ASP.Net MVC tricky scenario: a class implements two interfaces that … Read more

Get member to which attribute was applied from inside attribute constructor?

It’s possible from .NET 4.5 using CallerMemberName: [SomethingCustom] public string MyProperty { get; set; } Then your attribute: [AttributeUsage(AttributeTargets.Property)] public class SomethingCustomAttribute : Attribute { public StartupArgumentAttribute([CallerMemberName] string propName = null) { // propName == “MyProperty” } }