|
FxCop can do some preliminary (actually more the preliminary - if your rules are set right) analysis.
My signature "sucks" today
modified on Saturday, May 22, 2010 7:24 AM
|
|
|
|
|
There are two tools you can go with (simultanously):
1. FxCop (as mentioned by "Abhinav S").
2. StyleCop
The first one checks if your code conforms to rules Microsoft established for .NET applications design (for example methods, that don't use classes should be declared as static, all fields should be private).
The second one checks your code style (members should be commented, there should be single empty line between members).
Some of rules (like naming rules) are common for both those tools, some can only be found in one of them. Both are great way to learn to write clean and maintainable code.
|
|
|
|
|
StyleCop is new to me
I will download and test
Thanks
Life's Like a mirror. Smile at it & it smiles back at you.- P Pilgrim
So Smile Please
|
|
|
|
|
As it's my first post here I should probably say "Hello"
In WinForms application I'm developing I'd like to have a Panel (let's name it "controlContent"), that should be editable in inherited classes (I want to add controls to it) and second Panel, that will have some buttons common to all controls in this hierarchy. The problem is that when I do it the simplest way - by setting controlContent to be protected - StyleCop says, that field should not be protected, create property instead. Well obviously he's right. But when I create what he want's I don't have access through Visual Studio designer to the Panel. And of course I don't wan't to write controls' layout manually.
Did anyone have similar issue? How can I solve it? (I was searching web, but either I'm asking google wrong questions or answer isn't there).
|
|
|
|
|
StyleCop is right - field members should be private, but this is one of those circumstances where the only sensible way to do what you want is to set the field to protected. Just go with that and ignore the StyleCop rule.
"An eye for an eye only ends up making the whole world blind"
|
|
|
|
|
Yeah. That's what I'm doing right now. I was just wondering if there's some workaround. Either way thanks for your answer. And I'll still be waiting, maybe someone knows something
|
|
|
|
|
HI
Here i m try to do clear the Browser cookies.
When i m logout my Application
Here i removeall my session but when i m click to back button in my browser its navigating to my application page. But i want to show Login.aspx page could you tell me how to do this?
try and try untill reach success..
|
|
|
|
|
See here for cookies.
My signature "sucks" today
|
|
|
|
|
Hi Experts
Can you tell me how to create the own keyword in .net
like .net in-Built keyword like where,new,from etc..
Dinesh Sharma
|
|
|
|
|
As far as i know you can't.
Why would you want to? There may be a better or existing way to achieve what you want...
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
I think you may be a little confused: .NET has no "keywords" - the C# language has keywords, VB has a slightly different set of keywords, C++, F# etc. all have their own keywords.
What are you trying to achieve? If you explain, we may be able to help you to do it.
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
Actually i am learning LINQ then i see the keyword like from,order by, where etc. in my project which is winForm app. in VS 2005 then i am making DAL(Data Access Layer) for that project so i want to
create such type of keyword in that project..
|
|
|
|
|
You can't create your own keywords, unless you join the development team. MS has provided the ability to extend items, and this might be what you want to achieve. For instance, suppose you want all DataTables to have a Dump facility to dump the contents to a file, you could extend it using:
public static class Utility
{
public static void Dump(this DataTable datatable)
{
}
} This code then appears as an operation for an instance of the DataTable.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Pete - do extension methods work in VS2005? I know they came in at C#3.0, so they can't be used with .NET 2.0, but I'm not sure they exist in 2005. I can't check, I only have VS08 loaded.
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
It's the other way around, they can be used with .NET 2.0 (see below), but they can not be used (AFAIK) with VS05 because the version of the compiler it uses doesn't understand them. (unless you use custom build magic maybe)
Code to use extension methods with .NET 2.0:
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly)]
public sealed class ExtensionAttribute : Attribute
{
public ExtensionAttribute() { }
}
}
|
|
|
|
|
I thought I remembered there was something dodgy about the combination! Hopefully, the OP will spot this before he gets too confused...
Thanks for clearing that up.
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
Thank u harold aptroot for Appreciation.
|
|
|
|
|
No. As has been said, they can work in .NET 2, but they were introduced in .NET 3 which was released with VS2008. As the OP said he was dealing with LINQ however, it's a safe bet that he's using VS2008/VS2010.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
That's what I thought - but the OP post was talking about 2005, so that's why I asked. He probably has something a bit confused...
Sharma Dinesh Kumar wrote: in my project which is winForm app. in VS 2005
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
The best you can probably do is use extension methods[^].
My signature "sucks" today
|
|
|
|
|
public void InsertPlannedMaterialMasterRequest(int id, string requestDocument, string requestDescription, string requestType, string hodApproval, int companyCode, string hodRemarks, string det_Description, string name, int qty, string code)
{
string query = "INSERT INTO MasterRequest (ID,Req_Document,Req_Description,ReqType,HODApproval,CompanyCode,HODRemarks) VALUES (@ID,@Req_Document,@Req_Description,@ReqType,@HODApproval,@CompanyCode,@HODRemarks)";
SqlConnection con = new SqlConnection(constr);
SqlCommand com = new SqlCommand(query, con);
com.Parameters.Add("@ID", SqlDbType.Int).Value = id;
com.Parameters.Add("@Req_Document", SqlDbType.NVarChar).Value = requestDocument;
com.Parameters.Add("@Req_Description", SqlDbType.NVarChar).Value = requestDescription;
com.Parameters.Add("@ReqType", SqlDbType.NVarChar).Value = requestType;
com.Parameters.Add("@HODApproval", SqlDbType.NVarChar).Value = hodApproval;
com.Parameters.Add("@CompanyCode", SqlDbType.Int).Value = companyCode;
com.Parameters.Add("@HODRemarks", SqlDbType.NVarChar).Value = hodRemarks;
con.Open();
com.ExecuteNonQuery();
con.Close();
string query2 = "INSERT INTO DetailRequest (ID,Req_Document,Description,Approval) VALUES (@ID,@Req_Document,@Description,@Approval)";
SqlConnection con2 = new SqlConnection(constr);
SqlCommand com2 = new SqlCommand(query2, con2);
com2.Parameters.Add("@ID", SqlDbType.Int).Value = id;
com2.Parameters.Add("@Req_Document", SqlDbType.NVarChar).Value = requestDocument;
com2.Parameters.Add("@Description", SqlDbType.NVarChar).Value = det_Description;
com2.Parameters.Add("@Approval", SqlDbType.NVarChar).Value = hodApproval;
con2.Open();
com2.ExecuteNonQuery();
con2.Close();
string query3 = "INSERT INTO ITEMS (ID,Code,Name,Quantity) VALUES (@ID,@Code,@Name,@Quantity)";
SqlConnection con3 = new SqlConnection(constr);
SqlCommand com3 = new SqlCommand(query3, con3);
com3.Parameters.Add("@ID", SqlDbType.Int).Value = id;
com3.Parameters.Add("@Code", SqlDbType.NVarChar).Value = code;
com3.Parameters.Add("@Name", SqlDbType.NVarChar).Value = name;
com3.Parameters.Add("@Quantity", SqlDbType.Int).Value = qty;
con3.Open();
com3.ExecuteNonQuery();
con3.Close();
}
protected void Button1_Click(object sender, EventArgs e)
{
MasterRequest_DAL helper = new MasterRequest_DAL();
PlannedMaterialRequest pnd = new PlannedMaterialRequest();
ItemsHandling itm = new ItemsHandling();
string[] labelName = new string[100];
string[] coder = new string[100];
string[] quantity = new string[100];
if (TextBox6.Text != "0")
{
labelName[1] = itm.Code(0).ToString();
labelName[2] = TextBox6.Text;
helper.InsertPlannedMaterialMasterRequest(Convert.ToInt32(TextBox1.Text), TextBox2.Text, TextBox4.Text, DropDownList6.SelectedValue, DropDownList2.SelectedValue, Convert.ToInt32(TextBox11.Text), TextBox12.Text, TextBox13.Text, Label8.Text, Convert.ToInt32(TextBox6.Text), labelName[1]);
}
if (TextBox12.Text != "0")
{
labelName[1] = itm.Code(1).ToString();
labelName[2] = TextBox12.Text;
helper.InsertPlannedMaterialMasterRequest(Convert.ToInt32(TextBox1.Text), TextBox2.Text, TextBox4.Text, DropDownList6.SelectedValue, DropDownList2.SelectedValue, Convert.ToInt32(TextBox11.Text), TextBox12.Text, TextBox13.Text, Label12.Text, Convert.ToInt32(TextBox8.Text), labelName[1]);
}
}
The problem I am facing is that using the above code. The ID goes multiple times in MasterRequest table which should go only once, while the same ID must go to Items table multiple times as per the quantities being entered. I want only the ID to go into MasterRequest table just once not multiple times.
|
|
|
|
|
Do you want to say the it insert data into the MasterRequest table multiple times? Is there any postback issues.
|
|
|
|
|
yes this is exactly what it is happening. I just want the ID to enter into Master Request table for once while the same ID to enter into ITEMS table as many times the quantities are entered.
|
|
|
|
|
Thanks to all who assisted. My little flow calculator, ugly stepchild that it is, works nicely now.
My boss thanks you, my HP-15c calculator thanks you; my work PC has mixed feelings...
For the next version I'm going to figure out how to draw my pipe and channel cross-sections, rather than do them in AutoCAD, export them to pdf in CutePDF, import them and resize them in GIMP 2, then save them as jpg so Windows can render them.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Great. This may be the right time to write that long overdue second article, and tell us a bit about flow equations.
PS: points for a unique subject line!
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|