Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5936041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:20:32+00:00 2026-05-22T15:20:32+00:00

I often find that attributes can be too large. Sometimes it feels like the

  • 0

I often find that attributes can be too large.
Sometimes it feels like the attributes take up more of the screen than the code.
It can make it hard to spot the method names.

Also, they are not reusable, so you can end up repeating your values a lot.

To counter this I considered creating my own attribute class, which inherits from the required
attribute, and just sets all the properties to the defaults I need.
However, in most cases attributes are sealed, putting a stop to my schemes.

Is there any alternative to large attributes?


As a random example of what I’m talking about:

[SoapDocumentMethod(
    "http://services.acme.co.uk/account/Web/GetCustomerDetails/GetCustomerDetails", 
    RequestNamespace = "http://services.acme.co.uk/account/Web", 
    ResponseNamespace = "http://services.acme.co.uk/account/Web", 
    Use = SoapBindingUse.Literal, 
    ParameterStyle = SoapParameterStyle.Wrapped)]
public Response GetCustomerDetails(Request request)
{
    //...
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T15:20:33+00:00Added an answer on May 22, 2026 at 3:20 pm

    From my point of view there’re many options.

    One would be with code generation. You can use T4 engine in order to read some configuration file and apply some attributes to an arbitrary member.

    Learn more about T4 on http://msdn.microsoft.com/en-us/library/ff697195.aspx

    Sometimes some class is part of some hierarchy and you can use some attribute in an abstract or virtual member, so derived classes overriding these wouldn’t need that attribute since it’s declared already in the base member.

    About readability, you can use regions in order to hide members’ attributes.

    Anyways, I’ll suggest you code generation approach, because it’s the cleanest and simpler solution. Right, this isn’t an alternative, because you’ll have the exact code, but you’ll avoid doing it by hand.

    Finally, most of .NET APIs and third-party ones allows you to configure things with attributes or with some object model, so, maybe, when you find that you’ve your code full of attributes, some things could be made by creating your own configuration schema and use library’s object model in order to configure your environment.

    EDIT

    I want to add that if you like code generation approach, you can use custom attributes that will be replaced by right ones when some code template is executed over some file.

    A sample of that could be:

    [SomeFake]
    public void A() {}
    
    ... and after code generation
    
    [SomeActual(Allow = true, Loggable = true)]
    public void A() {}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I often find myself writing a property that is evaluated lazily. Something like: if
With more and more projects under my belt I find that I am often
I have been creating Unit tests like crazy and find that I'm often having
I find that quite often Visual Studio memory usage will average ~150-300 MB of
I find that the .NET event model is such that I'll often be raising
While creating classes in Java I often find myself creating instance-level collections that I
Often I find myself filling ASP.NET repeaters with items that need the CSS class
I often find myself with fairly complex data that represents something that my objects
I feel like this is a silly question but I always find that modifying
I often find I have class instances that are descendants of other class instances,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.