[prev in list] [next in list] [prev in thread] [next in thread]
List: sonar-dev
Subject: Re: [sonar-dev] Sonar .Net dependencies & DSM
From: mathias kluba <mathias.kluba () gmail ! com>
Date: 2012-02-29 7:51:08
Message-ID: CAKUF=z6x_tuyC91YD5jucgR8tkmSiF13fmfeVgo4LO-+5oY3HA () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
uhmmm.. static can do the trick I test that latter...
On Wed, Feb 29, 2012 at 8:36 AM, mathias kluba <mathias.kluba@gmail.com>wrote:
> @Alejandro:
> Hi, sure you can forke the Github repo, but if you really need something
> "out of the box" right now, http://www.ndepend.com/ is better for you.
>
> @Alexandre:
> I already package the tool as a runner (as Gendarme runner for exemple)
> I saw the CsharpResourceBridge, and I use it.
> I already made some progress about type<->type dependency, but it's not
> working
> https://github.com/grozeille/sonar-plugin-dotnet/commits/master
>
> The problem is:
> - I parse the dependencies per projects (1 file per project) but this
> project may have dependencies to other projects (which will be parsed after)
> So I keep in "cache" (a private field) the result of the XML parsing, but
> I don't save it right now
> Also, when I user "CsharpResourceBridge", I need it from "Project A" to
> get the type to "Project B", but "CsharpResourceBridge" contains only
> data of the current project.
> - at the end, when I do the dependency Analysis on the "project.isRoot()
> == true", I compute all Dependency objects thanks to the result in
> cache.... but because it's always a new instance of the class, I lost all
> data and I'm not able to save type-to-type Dependency
>
> Question: is it possible to share data between analysis of different
> projects?
> Is there another way to do that?
> I can parse all XML on the Project level, but I don't like that solution...
>
> Thanks by advance!
> Regards.
>
>
> On Mon, Feb 27, 2012 at 12:33 PM, Alejandro Batista Fernandez <
> alejandro.batista@gmail.com> wrote:
>
>> Hey Mathias,
>>
>> This is great stuff!!
>> Thank you very much for the update. I'll get your code and I'll give a
>> try to it.
>> Since I'm trying to implement Sonar on my company, I can try to "sell"
>> management to get some of my time to help you.
>>
>> I've been more focused on .net the last 5 years but I think I still
>> remember a few java tricks.
>> Would you be interested? Did you identified areas where I can make some
>> progress??
>>
>> -Alejandro
>>
>>
>> 2012/2/26 Alexandre Victoor <alexvictoor@gmail.com>
>>
>>> Great !
>>> Thanks a lot Mathias
>>> You need to use the CsharpResourceBridge component in order to make the
>>> link between a type and a source file.
>>> Now we need to find a way to store/dowload your dependency parser
>>> binaries...
>>> Regards
>>>
>>> Alex
>>> Le 26 févr. 2012 18:53, "Mathias Kluba" <mathias.kluba@gmail.com> a
>>> écrit :
>>>
>>> Hi,
>>>>
>>>> I decided to work on Dependency management in Sonar .Net.
>>>> I made a small .Net tool to scan dependencies of binaries, to generate
>>>> an XML report (using the wonderful Mono.Cecil).
>>>> https://github.com/grozeille/DependencyParser
>>>>
>>>> I updated the Sonar .Net plugin to the last SVN Trunk, and merged my 1
>>>> year old work.
>>>> I updated the parser to use the small "DependencyParser" tool instead
>>>> of parsing the CSProj.
>>>> The sources are available here:
>>>> https://github.com/grozeille/sonar-plugin-dotnet
>>>>
>>>> Here the result:
>>>>
>>>> Be able to search usage of assemblies:
>>>>
>>>> Be able to display all dependencies of projects of a solution:
>>>>
>>>>
>>>>
>>>>
>>>> And the Depency Matrix:
>>>>
>>>>
>>>> I now plan to parse dependencies between files.
>>>> I can also use Mono.Cecil because it's very easy to detect all used
>>>> types in a class, but I have to "guess" the source file corresponding to
>>>> the class.
>>>> I can use the Sonar CSharp parser, but I don't know how it works for
>>>> now...
>>>>
>>>> PS: I also updated the "Design" plugin to enable the "Design" tab and
>>>> the "Libraries" tab for CSharp langage.
>>>>
>>>> It's a first "alpha" version. If you want to test it, I can send you
>>>> the binaries.
>>>> Feel free to leave your comments or suggestions.
>>>>
>>>> Regards.
>>>>
>>>> Le 22/02/2012 09:33, Alejandro Batista Fernandez a écrit :
>>>>
>>>>
>>>> Yep sorry, I was talking about assemblies circular references, which
>>>> probably on latests versions of Visual Studio can be also detected, but as
>>>> I told you we have millions of LoC from 2000 to the present.
>>>>
>>>> For solving such an issue they came up with a Service Locator, which
>>>> is also something I'm trying to demonstrate it's not the solution. We need
>>>> to go for a real IoC and fix dependencies between assemblies by separating
>>>> Abstractions (Interfaces) from Concretions (Impl. Classes)
>>>>
>>>> Let's see what we can do.
>>>>
>>>> No worries about french monodevelop :) I can understand written (and
>>>> some spoken) french
>>>>
>>>> Again, thanks a lot for your help.
>>>>
>>>> -Alejandro
>>>>
>>>> 2012/2/22 Mathias Kluba <mathias.kluba@gmail.com>
>>>>
>>>>> What kind of circular reference do you have?
>>>>> Sorry for my "French" version of Monodevelop, but here is what I have
>>>>> when I try to reference A to B and B to A:
>>>>>
>>>>> (In french "Circular references not authorized)
>>>>>
>>>>> Now, I A refers to B, and B referes to C, I can't do "C refers to A"
>>>>>
>>>>>
>>>>> But I guess you can do circular references through assemblies... I
>>>>> never thought about that....
>>>>> And it seems to not be detected in runtime...
>>>>>
>>>>> OK so I guess that in this case you really have to parse Assemblies
>>>>> to detect dependencies!
>>>>> good luck :) your work will help me a lot :)
>>>>>
>>>>> Le 21 févr. 2012 à 23:43, Alejandro Batista Fernandez a écrit :
>>>>>
>>>>> Thank you very much for your so detailed answer.
>>>>> Your feedback is highly appreciated. I'll take all this in account.
>>>>>
>>>>> The fact is, we have circular reference in .NET (millions of lines
>>>>> of legacy code). We are actually using Lattix. Maybe best approach, instead
>>>>> retaking your idea, it's to parse lattix output and integrate it within
>>>>> sonar db (I dont even know whether it's possible or not)
>>>>>
>>>>> Anyway, thank you so much for your answer.
>>>>>
>>>>> -Alejandro
>>>>>
>>>>> 2012/2/21 mathias kluba <mathias.kluba@gmail.com>
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I started to do it last year...
>>>>>> So maybe the base code changed a lot, and my work is no more
>>>>>> compatible...
>>>>>>
>>>>>> Here is what I did:
>>>>>> - change the maven dotnet core jar, to save the "csproj" as "maven
>>>>>> modules" instead of independent projects.
>>>>>> - parse the CSProj to list dependencies (to binaries or other csproj)
>>>>>> - change the Design plugin to display the Design/Libraries tab also
>>>>>> for .Net
>>>>>>
>>>>>> I stopped to work on it because it was very limited:
>>>>>> - you can't do circular dependencies int .Net (assembly A refers to
>>>>>> assembly B which refers to assembly A) as in Java: the compilation unit is
>>>>>> the Assembly, not the class. So it's not usefull to detect cycles..
>>>>>> - I parsed only the CSProj, not the assemblies to detect the
>>>>>> "assemblies dependencies" (transitive dependencies). It could be done in
>>>>>> .Net, with Mono.Cecil or simple Reflection, as it's done in ILSpy for
>>>>>> example. Should I create a new tool to generate XML and parse it in Sonar
>>>>>> plugin? IKVM can compile Java in .Net, but I don't know any free tool to do
>>>>>> the oposite (and parse the .Net IL from Java)
>>>>>> - I didn't parsed dependencies between classes/files/methods: it
>>>>>> could also be done using .Net Mono.Cecil but it's not accurate because it's
>>>>>> parsing the generated assembly. It can be done using CodeDOM parser, or
>>>>>> with the latest source parser Roslyn... But I know that Sonar implemented
>>>>>> their own source parser in Java, which can be used to do that too.
>>>>>>
>>>>>> I don't have a lot of free time now to work on it, but I could help.
>>>>>>
>>>>>> Regards.
>>>>>>
>>>>>>
>>>>>> On Tue, Feb 21, 2012 at 1:56 PM, Alejandro Batista Fernandez <
>>>>>> alejandro.batista@gmail.com> wrote:
>>>>>>
>>>>>>> Forgot to include the link:
>>>>>>> http://article.gmane.org/gmane.comp.java.sonar.devel/5502/match=dsm+c%23
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> 2012/2/21 Alejandro Batista Fernandez <alejandro.batista@gmail.com>
>>>>>>>
>>>>>>>> Hi Mathias,
>>>>>>>>
>>>>>>>> I came across the web looking for Dependency Structure Matrix -
>>>>>>>> Sonar support for dot net projects. I've found a mail thread where you were
>>>>>>>> discussing with Alexander some patch you had already done. I also can see
>>>>>>>> you have forked sonar source on git.
>>>>>>>> Were you able to include DSM for .net?
>>>>>>>>
>>>>>>>> I need to support DSM on a sonar analysis (base on java
>>>>>>>> sonar-runner) I'm implementing and I want to make sure I have no other
>>>>>>>> choice that writing support myself before starting.
>>>>>>>>
>>>>>>>> Thanks in advance,
>>>>>>>> Alejandro
>>>>>>>>
>>>>>>>> PS: great blog BTW.
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>
>
[Attachment #5 (text/html)]
uhmmm.. static can do the trick I test that latter...<br><br><div \
class="gmail_quote">On Wed, Feb 29, 2012 at 8:36 AM, mathias kluba <span \
dir="ltr"><<a href="mailto:mathias.kluba@gmail.com">mathias.kluba@gmail.com</a>></span> \
wrote:<br> <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px \
#ccc solid;padding-left:1ex"><div>@Alejandro: </div><div>Hi, sure you can forke the \
Github repo, but if you really need something "out of the box" right now, \
<a href="http://www.ndepend.com/" target="_blank">http://www.ndepend.com/</a> is \
better for you.</div><div><br></div><div>@Alexandre: </div><div>I already package the \
tool as a runner (as Gendarme runner for exemple)</div> <div>I saw the \
<span>CsharpResourceBridge, and I use it. </span></div> <div>I already made some \
progress about type<->type dependency, but it's not working</div><div><a \
href="https://github.com/grozeille/sonar-plugin-dotnet/commits/master" \
target="_blank">https://github.com/grozeille/sonar-plugin-dotnet/commits/master</a> \
</div>
<div><br></div><div>The problem is:</div><div>- I parse the dependencies per projects \
(1 file per project) but this project may have dependencies to other projects (which \
will be parsed after)</div><div>So I keep in "cache" (a private field) the \
result of the XML parsing, but I don't save it right now</div>
<div>Also, when I user "<span>CsharpResourceBridge", I need it from \
"Project A" to get the type to "Project B", but \
"</span><span>CsharpResourceBridge" contains only data of the current \
project.</span></div>
<div>- at the end, when I do the dependency Analysis on the "project.isRoot() == \
true", I compute all Dependency objects thanks to the result in cache.... but \
because it's always a new instance of the class, I lost all data and I'm not \
able to save type-to-type Dependency</div>
<div><br></div><div>Question: is it possible to share data between analysis of \
different projects?</div><div>Is there another way to do that?</div><div>I can parse \
all XML on the Project level, but I don't like that solution...</div>
<div><br></div><div>Thanks by advance!</div><div>Regards.<div><div \
class="h5"><br><br><div class="gmail_quote">On Mon, Feb 27, 2012 at 12:33 PM, \
Alejandro Batista Fernandez <span dir="ltr"><<a \
href="mailto:alejandro.batista@gmail.com" \
target="_blank">alejandro.batista@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div>Hey Mathias,</div><div><br></div>This is great \
stuff!!<div>Thank you very much for the update. I'll get your code and I'll \
give a try to it.</div>
<div>Since I'm trying to implement Sonar on my company, I can try to \
"sell" management to get some of my time to help you.</div> \
<div><br></div><div>I've been more focused on .net the last 5 years but I think I \
still remember a few java tricks.</div><div>Would you be interested? Did you \
identified areas where I can make some progress??</div><span><font \
color="#888888"><div>
<br></div></font></span><div><span><font \
color="#888888">-Alejandro</font></span><div><div><br><br><div \
class="gmail_quote">2012/2/26 Alexandre Victoor <span dir="ltr"><<a \
href="mailto:alexvictoor@gmail.com" \
target="_blank">alexvictoor@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"> <p>Great !<br>
Thanks a lot Mathias<br>
You need to use the CsharpResourceBridge component in order to make the link between \
a type and a source file. <br> Now we need to find a way to store/dowload your \
dependency parser binaries...<br> Regards</p>
<p>Alex</p>
<div class="gmail_quote">Le 26 févr. 2012 18:53, "Mathias Kluba" <<a \
href="mailto:mathias.kluba@gmail.com" target="_blank">mathias.kluba@gmail.com</a>> \
a écrit :<div><div><br type="attribution"> <blockquote class="gmail_quote" \
style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
Hi,<br>
<br>
I decided to work on Dependency management in Sonar .Net.<br>
I made a small .Net tool to scan dependencies of binaries, to
generate an XML report (using the wonderful Mono.Cecil).<br>
<a href="https://github.com/grozeille/DependencyParser" \
target="_blank">https://github.com/grozeille/DependencyParser</a><br> <br>
I updated the Sonar .Net plugin to the last SVN Trunk, and merged my
1 year old work.<br>
I updated the parser to use the small "DependencyParser" tool
instead of parsing the CSProj.<br>
The sources are available here: <a \
href="https://github.com/grozeille/sonar-plugin-dotnet" \
target="_blank">https://github.com/grozeille/sonar-plugin-dotnet</a><br> <br>
Here the result:<br>
<br>
Be able to search usage of assemblies:<br>
<img src="cid:part1.02030606.08070307@gmail.com" alt="" height="284" \
width="664"><br> Be able to display all dependencies of projects of a solution:<br>
<img src="cid:part2.00090205.04050902@gmail.com" alt="" height="476" \
width="455"><br> <br>
<br>
<br>
And the Depency Matrix:<br>
<img src="cid:part3.06000401.08020501@gmail.com" alt="" height="241" \
width="453"><br> <br>
I now plan to parse dependencies between files.<br>
I can also use Mono.Cecil because it's very easy to detect all used
types in a class, but I have to "guess" the source file
corresponding to the class.<br>
I can use the Sonar CSharp parser, but I don't know how it works for
now...<br>
<br>
PS: I also updated the "Design" plugin to enable the "Design" \
tab and the "Libraries" tab for CSharp langage.<br>
<br>
It's a first "alpha" version. If you want to test it, I can send \
you the binaries.<br>
Feel free to leave your comments or suggestions.<br>
<br>
Regards.<br>
<br>
Le 22/02/2012 09:33, Alejandro Batista Fernandez a écrit :
<blockquote type="cite">
<div><br>
</div>
Yep sorry, I was talking about assemblies circular references,
which probably on latests versions of Visual Studio can be also
detected, but as I told you we have millions of LoC from 2000 to
the present.
<div>
<br>
</div>
<div>For solving such an issue they came up with a Service
Locator, which is also something I'm trying to demonstrate it's
not the solution. We need to go for a real IoC and fix
dependencies between assemblies by separating Abstractions
(Interfaces) from Concretions (Impl. Classes)</div>
<div><br>
</div>
<div>Let's see what we can do.</div>
<div><br>
</div>
<div>No worries about french monodevelop :) I can understand
written (and some spoken) french</div>
<div><br>
</div>
<div>Again, thanks a lot for your help.</div>
<div><br>
</div>
<div>-Alejandro<br>
<br>
<div class="gmail_quote">2012/2/22 Mathias Kluba <span dir="ltr"><<a \
href="mailto:mathias.kluba@gmail.com" \
target="_blank">mathias.kluba@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px \
#ccc solid;padding-left:1ex"> <div style="word-wrap:break-word">
<div>What kind of circular reference do you have?</div>
<div>Sorry for my "French" version of Monodevelop, but
here is what I have when I try to reference A to B and B
to A:</div>
<div><img src="cid:part4.07010009.00000307@gmail.com" height="303" \
width="547"></div> <div><br>
</div>
<div>(In french "Circular references not authorized)</div>
<div><br>
</div>
<div>Now, I A refers to B, and B referes to C, I can't do
"C refers to A"</div>
<div><img src="cid:part5.04050600.04040707@gmail.com" height="255" \
width="525"></div> <div><br>
</div>
<div><br>
</div>
<div>But I guess you can do circular references through
assemblies... I never thought about that....</div>
<div><img src="cid:part6.01020006.05060602@gmail.com" height="232" \
width="215"></div> <div>And it seems to not be detected in runtime...</div>
<div><br>
</div>
<div>OK so I guess that in this case you really have to
parse Assemblies to detect dependencies!</div>
<div>good luck :) your work will help me a lot :)</div>
<br>
<div>
<div>Le 21 févr. 2012 à 23:43, Alejandro Batista
Fernandez a écrit :</div>
<div>
<div><br>
<blockquote type="cite">Thank you very much for your
so detailed answer.
<div>
Your feedback is highly appreciated. I'll take
all this in account.</div>
<div><br>
</div>
<div>The fact is, we have circular reference in
.NET (millions of lines of legacy code). We are
actually using Lattix. Maybe best approach,
instead retaking your idea, it's to parse lattix
output and integrate it within sonar db (I dont
even know whether it's possible or not)</div>
<div><br>
</div>
<div>Anyway, thank you so much for your answer.</div>
<div><br>
</div>
<div>-Alejandro<br>
<br>
<div class="gmail_quote">2012/2/21 mathias kluba
<span dir="ltr"><<a \
href="mailto:mathias.kluba@gmail.com" \
target="_blank">mathias.kluba@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 \
.8ex;border-left:1px #ccc solid;padding-left:1ex">Hi, <div><br>
</div>
<div>I started to do it last year...</div>
<div>So maybe the base code changed a lot,
and my work is no more compatible...</div>
<div><br>
</div>
<div>Here is what I did:</div>
<div>- change the maven dotnet core jar, to
save the "csproj" as "maven \
modules" instead of independent projects.</div>
<div>- parse the CSProj to list dependencies
(to binaries or other csproj)</div>
<div>- change the Design plugin to display
the Design/Libraries tab also for .Net</div>
<div><br>
</div>
<div>I stopped to work on it because it was
very limited:</div>
<div>- you can't do circular dependencies
int .Net (assembly A refers to assembly B
which refers to assembly A) as in Java:
the compilation unit is the Assembly, not
the class. So it's not usefull to detect
cycles..</div>
<div>- I parsed only the CSProj, not the
assemblies to detect the "assemblies
dependencies" (transitive dependencies).
It could be done in .Net, with Mono.Cecil
or simple Reflection, as it's done in
ILSpy for example. Should I create a new
tool to generate XML and parse it in Sonar
plugin? IKVM can compile Java in .Net, but
I don't know any free tool to do the
oposite (and parse the .Net IL from Java)</div>
<div>- I didn't parsed dependencies between
classes/files/methods: it could also be
done using .Net Mono.Cecil but it's not
accurate because it's parsing the
generated assembly. It can be done using
CodeDOM parser, or with the latest source
parser Roslyn... But I know that Sonar
implemented their own source parser in
Java, which can be used to do that too.</div>
<div><br>
</div>
<div>I don't have a lot of free time now to
work on it, but I could help.</div>
<div><br>
</div>
<div>Regards.</div>
<div>
<div>
<div> <br>
<br>
<div class="gmail_quote">On Tue, Feb
21, 2012 at 1:56 PM, Alejandro
Batista Fernandez <span dir="ltr"><<a \
href="mailto:alejandro.batista@gmail.com" \
target="_blank">alejandro.batista@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 \
0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Forgot to include the link:
<a \
href="http://article.gmane.org/gmane.comp.java.sonar.devel/5502/match=dsm+c%23" \
target="_blank">http://article.gmane.org/gmane.comp.java.sonar.devel/5502/match=dsm+c%23</a> \
<div>
<div><br>
<br>
<div class="gmail_quote">2012/2/21
Alejandro Batista Fernandez
<span dir="ltr"><<a \
href="mailto:alejandro.batista@gmail.com" \
target="_blank">alejandro.batista@gmail.com</a>></span><br>
<blockquote class="gmail_quote" \
style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Mathias,
<div><br>
<div>I came across the
web looking for
Dependency Structure
Matrix - Sonar support
for dot net projects.
I've found a mail
thread where you were
discussing with
Alexander some patch
you had already done.
I also can see you
have forked sonar
source on git.</div>
<div>Were you able to
include DSM for .net?</div>
<div><br>
</div>
<div>I need to support
DSM on a sonar
analysis (base on java
sonar-runner) I'm
implementing and I
want to make sure I
have no other choice
that writing support
myself before
starting.</div>
<div><br>
</div>
<div>Thanks in advance,</div>
<div>Alejandro</div>
<div><br>
</div>
<div>PS: great blog
BTW. </div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
</div>
</div>
</div>
<br>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
</div>
</blockquote></div></div></div>
</blockquote></div><br></div></div></div>
</blockquote></div><br></div></div></div>
</blockquote></div><br>
--20cf306f72044d689f04ba159b37--
["iadechbe.png" (image/png)]
["ghejehaf.png" (image/png)]
[Attachment #8 (image/png)]
[Attachment #9 (image/png)]
[Attachment #10 (image/png)]
["abhdihdg.png" (image/png)]
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic