SolutionGuidGenerator.cs 911 B

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using System.Security.Cryptography;
  3. using System.Text;
  4. namespace Packages.Rider.Editor.ProjectGeneration
  5. {
  6. internal static class SolutionGuidGenerator
  7. {
  8. public static string GuidForProject(string projectName)
  9. {
  10. return ComputeGuidHashFor(projectName + "salt");
  11. }
  12. public static string GuidForSolution(string projectName, string sourceFileExtension)
  13. {
  14. if (sourceFileExtension.ToLower() == "cs")
  15. // GUID for a C# class library: http://www.codeproject.com/Reference/720512/List-of-Visual-Studio-Project-Type-GUIDs
  16. return "FAE04EC0-301F-11D3-BF4B-00C04F79EFBC";
  17. return ComputeGuidHashFor(projectName);
  18. }
  19. static string ComputeGuidHashFor(string input)
  20. {
  21. using (var md5 = MD5.Create())
  22. {
  23. var hash = md5.ComputeHash(Encoding.Default.GetBytes(input));
  24. return new Guid(hash).ToString();
  25. }
  26. }
  27. }
  28. }