質問

I am trying to create class diagrams through code. Since CD files are XML files, it should be straight way to generate the files from classes. But the problem is I don't know how to get the hash code to embed in the type identifier.

Below is the XML generated by VS for a class.

<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram MajorVersion="1" MinorVersion="1">
  <Class Name="NVTest.Program" Collapsed="true">
    <Position X="0.5" Y="0.5" Width="1.5" />
    <TypeIdentifier>
      <HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAA=</HashCode>
      <FileName>Program.cs</FileName>
    </TypeIdentifier>
  </Class>
<Font Name="Segoe UI" Size="9" />
</ClassDiagram>

Assuming that the hashcode is a base64 string, I tried to generate it from class def. as

Convert.ToBase64String((BitConverter.GetBytes(typeof(Program).GetHashCode())))

but the result is: nJ4uAA==

So, how to generate the HashCode?

Thanks

役に立ちましたか?

解決

While I don't know how that hashcode is generated, not having the HashCode element in .cd files doesn't seem to make a difference to the Class Diagram viewer. So you may try generating those files without any HashCode.

他のヒント

Just uninstall Class Designer from Visual Studio\Invidual components\Code tools then you can get hashcode from you class file.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top