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 301105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:58:30+00:00 2026-05-12T06:58:30+00:00

I have a method of an object which is something like a factory. You

  • 0

I have a method of an object which is something like a factory. You give it a type, it creates an instance and does a few other things. An elegant way to do it (in my opinion) is like this:

public T MagicMethod<T>() where T: SomeBaseClass
{
    // Magic goes here
}

But this upsets FxCop who says that this is a bad style – I get a “CA1004: Generic methods should provide type parameter” warning. Something about not being to use inference and stuff. So, the only other way I can think of is something like this:

public SomeBaseClass MagicMethod(Type T)
{
    // Same magic goes here
}

I believe this is inferior to the first method on many accounts, but the style rule… The MSDN article on the warning even says that there is no reason for suppressing it.

Am I doing it right by suppressing this warning after all?

  • 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-12T06:58:31+00:00Added an answer on May 12, 2026 at 6:58 am

    FXCop warnings are just that – warnings. Just like implicit cast warnings, they serve to let you know that something you’re doing may have behavior you’re not anticipating, or may not be what you intended.

    An implicit cast warning is dealt with by looking at the code, determinining if you really did intend to do that, and if so, adding an explicit cast.

    Same thing with FXCop. Look at the warning, look at your code, and determine if the warning is valid. If it is, fix it. If not, suppress it. A suppression is the equivalent of an explicit cast – “Yes, FXCop, I’m sure I want to do this.”

    If it was really truly an error, it would probably be a compiler error.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a seed object which has an instance method seed:fall() which is called
I have a method named RenderContent which returns object[] In my unit test, I
Suppose I have a method which changes the state of an object, and fires
Let's say I have a WCF service which has a method returning object Person.
I have the following method which serialises an object to a HTML tag. I
I have a service method that calls a DAO which then returns an object
I have a JNI method to access java method which returns an Integer object.
I have my main application delegate which contains a method that returns an object.
I have an object class called BOM. It has a method, getChildItem() which returns
I have some code, which uses the ExecuteStmt method on the Axapta Object when

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.