473,398 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

FXCop - had problems with it, example the needs of Object.Equals()

Hi there,

I am super confuse on this recommendation by FxCop.

1)
http://www.gotdotnet.com/team/fxcop/...Overridel.html

First of all, let me explain how i see that problem:

I had a C program that does this:

typedef unsigned char uint8;
typedef uint8 *puint8;

typedef struct TagStructure
{
uint8 var1;
uint8 var2;
puint8 HeaderIN;
puint8 HeaderOut;
}

I try to code this in C#:

public class PortExample : IDisposable
{
private bool disposed = false;

public PortExample()
{

}

~PortExample()
{
Dispose(false);
}

[StructLayout(LayoutKind.Sequential)]
public struct TagStructure
{
private int field;

private byte var1;
private byte var2;
public TagInstruction(int value)
{
field = value;
}

public byte Var1
{
get
{
return var1;
}
set
{
this.var1 = value;
}
}

public byte Var2
{
get
{
return var2;
}
set
{
this.var2 = value;
}
}
public readonly IntPtr HeaderIN;
public readonly IntPtr HeaderOut;
}

#region IDisposable Members

public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}

protected virtual void Dispose(bool disposing)
{

if (!disposed)
{
if (disposing)
{
// Release managed resources
}
disposed = true;
}
}

#endregion

The problems is i had no idea why should i placed Object.Equals() here, why? I don't even compare an object with another object. Also it mentions that something related to value type. I am confuse.

2)
I also declare this in my structure. FXcop recommends me to use readonly or private. Well my other class (different file) needs to call this structure, and use this pointer. If i use private, i don't think it will work. But if i use readonly, i can't point to any other address, as I believe readonly, you can't change the value. How do i solve this issue?

public readonly IntPtr HeaderIN;
public readonly IntPtr HeaderOut;

3) FxCop also recommends me to use a non parameterless constructor inside the struct.

public TagInstruction(int value)
{
field = value;
}

The problem, i don't see why i should place the constructor in there for? I don't need it.

Any help please? Thanks.
--
Regards,
Chua Wen Ching :)
Nov 16 '05 #1
0 1294

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Raymond Lewallen | last post by:
I know FxCop has its own board on the FxCop website, but I wanted to reach a larger audience. Has anyone here written any custom rules based on the Introspection engine? Even if you have some...
6
by: Omar | last post by:
Hi, In a JSP I have the next: .... codigo = "<select name='" + nombre + "'>\n<option selected value='default'>Escoge</option><option value='todos'>Todos</option>"; if (miRS != null) while...
10
by: BBFrost | last post by:
We just recently moved one of our major c# apps from VS Net 2002 to VS Net 2003. At first things were looking ok, now problems are starting to appear. So far ... (1) ...
5
by: Chua Wen Ching | last post by:
I had use fxcop to check my code. I had 1 confusion here. I would normally call a method by this way in my IAnimal: Example: public void CallFuncA(ushort port); But fxcop says i need to...
4
by: - Steve - | last post by:
I have a cs file I use in an ASP.NET form. The class has several member variables. If I assign a value to those variables in a method, when I get to another method the variable no longer equals...
8
by: hansiman | last post by:
Just beginning using FxCop in my asp.net projects... I get a lot of error messages under the header: AvoidUnusedParameters for funtions and routines lik: Sub isUserAuthenticated(ByVal...
2
by: Eric Sabine | last post by:
I'm running FX Cop on my assembly and on a form, tons of my labels and buttons are being flagged with this error. I don't really get the error and what I am supposed to do to resolve the error. I...
5
by: Peter Ritchie [C# MVP] | last post by:
I've purposely been ignoring a CA2122 warning in some C++ interop code I've been working on for quite some time. I've just recently had the cycles to investigate the warning. The warning message...
6
by: John Wright | last post by:
I ran FxCop against a program and was pleased with the security review except I get the following error: Do not indirectly expose methods How would I fix this code so this error goes away. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.