Banon
Banon

Reputation: 53

Locating Function Definition Within C#, .NET Project

I am looking through some C# code (NOTE: I generally work in JavaScript) that was originally done by a 3rd party vendor, and I'm trying to understand some of what I'm coming across.

In the code below you'll notice an Employee() function, to which I pass two params. Now, with this function the word "Employee" shows up in green, and I can right click on it to be taken to an Employee.cs file, so that's easy enough to trace and figure out what's going on.

However, in the function before that, where a new GPBaseFactory() is declared, it's less easy to understand, because that function does not show up in green, and I see no related file in my codebase. In other words, there is no GPBaseFactory.cs file. When I try and go to the file with F12 I get a pop-up with the message - "Cannot navigate to the symbol under the caret".

From what I can tell, GPBaseFactory() is also not a Microsoft-defined function that's part of GPDynamics.

Here is the code I just mentioned:

 // Save the employee
 var gp = new GPBaseFactory();
    
 var employee = new Employee(employee, gp.Transaction);
 employee.AddEmployeeToTransaction(employee);

I do see some using reference declarations at the top of this Program.cs file, however. Could it be that those are hidden, proprietary files, that contain the GPBaseFactory() function definition?

To test this theory, I tried commenting those out (I'm using Visual Studio 2019), but I don't get any warnings or errors in my code, suggesting it can't find something when I do so. So I'm just trying to make sense of this -- again, I regularly in Node/JS, not C# and .NET.

How can I determine what GPBaseFactory() refers to, and where the base function definition is located?

Upvotes: 0

Views: 364

Answers (1)

Steve Harris
Steve Harris

Reputation: 5109

Typically press F12 to go to the method definition. F12 on GPBaseFactory should open something at least. I expect it would show only empty methods saying 'from metadata' at the top. This indicates it is from a library that is not part of your code. It really depends on what that library is as to whether you will be able to access the code.

Upvotes: 1

Related Questions