public-method

Can findbugs detect unused public methods

五迷三道 提交于 2019-11-29 10:02:50
Is it possible to detect unused methods in a source tree using FindBugs? I see some posts on SO where users are claiming to do that, some others asking how to do this in FB and others where they claim FB cannot do this. Does anyone know for sure how this is done? I am only interested in methods that are not explicitly called from elsewhere, I don't care about reflection. as a member of the FindBugs team I can tell you that unfortunately FindBugs does not do this. If you search through the bug patterns on our website, the only mentions of "unused" detectors is for unused fields . I have a

How to retrieve all public methods from *.dll

蓝咒 提交于 2019-11-28 23:41:28
I have *.dll written with C# and I need to get list of all public methods or classes contained in that *.dll. Is there some way to do it programmatically with C#? Yes use Assembly.GetTypes to extract all of the types, and then use reflection on each type to iterate the public methods. Assembly a = Assembly.LoadWithPartialName("..."); Type[] types = a.GetTypes(); foreach (Type type in types) { if (!type.IsPublic) { continue; } MemberInfo[] members = type.GetMembers(BindingFlags.Public |BindingFlags.Instance |BindingFlags.InvokeMethod); foreach (MemberInfo member in members) { Console.WriteLine

JQuery - Widget Public Methods

霸气de小男生 提交于 2019-11-28 20:58:39
问题 If I create a JQuery widget (code example below), and then define a "public" method, is there any other way to call the method other than using the following form? $("#list").list("publicMethod"); I would like to create a series of widgets that all define the same methods (basically implementing the same interface), and be able to call the method without knowing anything about which widget I currently am invoking the method on. In the current form, I need to know that I am executing the

Reference to a non-shared member requires an object reference occurs when calling public sub

拟墨画扇 提交于 2019-11-28 11:54:53
I have a Public Class "General" in which is a Public Sub "updateDynamics". When I attempt to reference it in the code-behind for a page like so: updateDynamics(get_prospect.dynamicsID) I get the following error: reference to a non-shared member requires an object reference You either have to make the method Shared or use an instance of the class General : Dim gen = New General() gen.updateDynamics(get_prospect.dynamicsID) or General.updateDynamics(get_prospect.dynamicsID) Public Shared Sub updateDynamics(dynID As Int32) ' ... ' End Sub Shared(VB.NET) Go to the Declaration of the desired object

Why should we declare interface methods as public? [duplicate]

霸气de小男生 提交于 2019-11-28 06:16:19
This question already has an answer here: Protected in Interfaces 15 answers When I implement an interface method, I am forced to make it a public method. We may have cases where we want to use either the default (like in case of access within the same package) or protected . Can anyone please explain the reason behind this limitation? Interfaces are meant to define the public API of a type - and only that, not its implementation. So any method (or static member) you define in an interface is by definition public . Since an interface can't contain any concrete implementation, there is no way

What are the differences between “private”, “public”, and “protected methods”?

亡梦爱人 提交于 2019-11-28 05:16:40
I'm learning Ruby, and have come up to a point where I am confused. The book I am using is talking about private , public , and protected methods , but I am still a bit confused. What are the differences between each? Julio Marins Public - can be called from anywhere Private - The method cannot be called outside class scope. The object can only send the message to itself ex: the baker has bake method as public but break_eggs is private Protected - You can call an object's protected methods as long as the default object self is an instance of the same class as the object whose method you're

Disable “not used” warning for public methods of a class

。_饼干妹妹 提交于 2019-11-28 05:10:41
The new intellij upgrade (10.5) now shows a warning that some of the methods defined for a class are not being used. These methods are public and I plan on not using all of them as I have created them to support the API expected. I would like to disable this warning (not used for public methods in a class). Is there a way to do it?. You can disable it for a single method like this @SuppressWarnings("unused") public void myMethod(){...} IDEA 2016.3 In the upcoming version IDEA 2016.3 (preview version already available) it is now possible to adjust the inspection scope: < IDEA 14.0 If you want

Can findbugs detect unused public methods

情到浓时终转凉″ 提交于 2019-11-28 03:48:48
问题 Is it possible to detect unused methods in a source tree using FindBugs? I see some posts on SO where users are claiming to do that, some others asking how to do this in FB and others where they claim FB cannot do this. Does anyone know for sure how this is done? I am only interested in methods that are not explicitly called from elsewhere, I don't care about reflection. 回答1: as a member of the FindBugs team I can tell you that unfortunately FindBugs does not do this. If you search through

Access Of Public Method Between Forms

我怕爱的太早我们不能终老 提交于 2019-11-27 22:38:20
I am trying to get access to Form1’s public method on another form Form2 as below. I have a textbox6 control on form1 and there is public method to bind it. But I want to bind it by form2 as below. Form1 public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Form2 f2 = new Form2(); f2.Show(); } public void amount_sum() { string connstr = " server=.;initial catalog=maa;uid=mah;pwd=mah"; SqlConnection con = new SqlConnection(connstr); con.Open(); string sql = " select sum(amount)as amount from method"; SqlDataAdapter

public vs. internal methods on an internal class

旧街凉风 提交于 2019-11-27 18:54:33
internal class Foo { public void Fee() { Debug.WriteLine("Fee"); } internal void Fi() { Debug.WriteLine("Fi"); } } I'm thinking that Fee() and Fi() are equally accessible since the entire class is already internal. Am I overlooking something? Is there any reason to choose public or internal for the methods in a case like this? The internal class Foo declaration will override the accessibility of the public void Fee() method, effectively making it internal. In this case, using internal vs. public on the methods will have the same effect. The only reason I would choose public methods vs.