asp.net decompiled function is same but ndepend shows difference - ndepend

I have decompiled 2 .net 2.0 dlls (using a decompiler tool) and when I compare a function both are same. But when I compare these 2 assemblies, ndepend shows difference in ILInstructions and NBLinesOfCode.
Please let me know why ndepend is showing the function difference but decompiled code is same? if having differences (IL Instructions and LOC) in ndepend means the functionality is really different for 2 dlls?
What steps I can take to make the 2 assemblies same so that ndepend doesn't show difference in that function?
Please note I have lost original source code and I am trying to re-build the source code to make it original dll.

Related

Exclude test projects from Ndepend Analysis

I have a visual studio solution which has a lot of projects including unit test projects. I am using NDepend API to analyze the solution. The intention is to get the relationship between methods. I am doing this by using MethodsCalled and MethodsCallingMe. Since there are test projects in the solution. I am ending up with lot many relationships as the unit testcases call the actual implementation, which is unnecessary for what I am trying to achieve.
Is there a way to exclude unit test projects when analyzing the solution?
Ndepend - exclude assembly in some ways but not others
The link has some information not sure if this can be used with NDepend API.
Any help appreciated.
Are you getting your assemblies through this code?
// 2) obtains assemblies file path to analyze
var assembliesFilePath = (from vsSlnOrProjFilePath in vsSlnOrProjFilePaths
from assembliesFilePathTmp in visualStudioManager.GetAssembliesFromVisualStudioSolutionOrProject(vsSlnOrProjFilePath)
select assembliesFilePathTmp).Distinct().ToArray();
What about a LINQ filtering by assembly name, something like:
visualStudioManager.GetAssembliesFromVisualStudioSolutionOrProject(vsSlnOrProjFilePath)
.Where(a => !a.Name.ToLower().Contains("test"))

Trying to understand why Swift code compiles but can't link due to undefined symbols

I have a issue with the link phase failing due to undefined symbols. I'm looking to understand the general issue rather than a copy/paste solution for my specific setup.
Let's say I have 2 frameworks, and 1 target. framework B is linked to framework A and the target links with framework A only. The target does not link directly with framework B.
Swift files that contain "import A" are successfully compiling even though they reference objects contained in framework B. I guessing this is because the linkage between A > B makes all of B available when I import A.
However during the link phase, I get undefined symbol errors for anything contained in framework B. Adding "import B" in my file will again compile successfully, but still fail with the same link errors. Linking only succeeds If I directly link the target framework B.
I'd like for either of two scenarios to work:
Linking with framework A and "import A" also makes the link phase see symbols from framework B
Compilation fails to find objects in framework B unless I directly link with framework B and "import B"
Can someone shed some light on which of these scenarios is the "correct" one and why?
Thanks very much!

nDepend - get filtered assemblies to analyze

I am using nDepend and I wonder how can I tell nDepend that I'd like to analyze assemblies which names start with specfiic string (Test for example). What I see is that I need to provide full names of the assemblies and I cannot use any sort of wildcards.
Have you tried this?
NDepend Start Page
Analyze VS Solutions and VS Projects
Select a VS solution file
then on the up-right corner of the DataGridView use the filter capabilities (shown in screenshot below)

Converting UML class diagram to C++ code(VS 2012)

I am using VS2012 for a course project that we started from scratch, We are to use C++ to create something like this (I think the aggregation part is reversed):
https://www.dropbox.com/s/w2zh7yltbups6cm/class.png
Well , we had that on paper , wrote the code for each class with no problems, except we can't test because each class depends on another that was not finished at the time.
Long story short : each class has its own untested code and VS does not detect any errors whatsoever and based on our previous experience we know that the code is correct, no syntax errors anyway.
When I start compiling some 500 errors come out of nowhere , some of them it says in "time.h" , I thought it was something wrong with the compiler , tried switching to C::B and see if it work but i needed a different compiler and I don't have the time to download any large files ,seriously , deadline in 2 days and internet speed sucks.
doing some research here (and googling around) I narrowed it down to cyclic dependencies and I learned that I can draw the diagram in VS and get code files , unfortunately it does it in C# while I have a C++ code (it has to be C++) .
How can I realize this diagram in C++ ? Which class should include which headers ?
How can I avoid this in the future ?
EDIT:
Solved it by removing all dependencies and disabling pre-compiled headers (Don't really know if I had to) , then I included each .h in its corresponding .cpp , then I included in each .h every header it needs to use.
All that did not really solve my problem , it was the declarations !!!
I did #ifndef myclass , #define myclass to each header and declared the used classes , I think it's what's called "Forward Declaration" (correct me if I'm wrong)
Anyway it finally compiled and I will start testing .
If you have any remarks then by all means , you can add them.
Cyclic "dependency" can be. Why not? Because they are not dependencies, but associations with visible navigability. But you have some problems here.
Reservation should better have navigation to Member. Backward it could be, too. But Reservation should have Member instance as attribute. It is more simple way.
Also Rental is a class representation of association between DVD and Customer. And should have their instances as attributes. Again, back navigation IS possible, but do you need it? Maybe.
Another problem:
Title-DVD aggregation has correct direction, but it should be Composite, for there are no DVD without Title.
Testing: You can do unit tests, isolating classes from other ones by mocking first. After debugging that start to replace mocks with real classes. After that try unit tests without mocking, then normal auto tests, with automatic input/output/comparing.
As for code engineering, download VP UML enterprise "for testing version" and/or Enterprise Architect of Sparx, eval professional version. They both can do code engineering in C++.

How do you query .Net source for methods containing a string using NDepend?

I would like to find out all classes that have an inline SQL Statement in them. How do you write an NDepend CQL query that scans the method body looking for the use of say "Select"? Is it possible?
Thanks in Advance.
NDepend is more about code structure, code quality, code metrics, code diff ... It doesn't know about string constants content, so this is not the right tool for what you need to do.
For that I'd advise using Mono.Cecil which is an assembly content reader API (OSS/free) pretty well done! Btw NDepend relies on Cecil for reading assemblies and I can say it is a great API with high performances and pretty close to bug free!.