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