GuidFromStringAnalyzer is a small Roslyn analyzer that detects instantiations of
System.Guid with a string literal:
and provides the
Construct from integers fix-it to change them to the more efficient constructor using integers:
new Guid(0x26B5DB35, 0xC401, 0x4DE3, 0xB3, 0xD8, 0x20, 0x3F, 0xF9, 0xA0, 0xCA, 0x91);
The latter is directly embedded into the resulting assembly as a simple byte-array and requires no run-time parsing of the
GUID string. Roslyn currently does not optimize the string literals away on its own, see
the relevant issue.
GuidFromStringAnalyzer Visual Studio extension from the
Code licensed under the MIT License.