blob: 280fe8c84a1687b476e6aec573ee88c0503f5576 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Runtime.InteropServices;
namespace Microsoft.AspNetCore.Mvc.Razor.Internal
{
/// <summary>
/// Utility type for determining if a platform supports full pdb file generation.
/// </summary>
internal static class SymbolsUtility
{
// Native pdb writer's CLSID
private const string SymWriterGuid = "0AE2DEB0-F901-478b-BB9F-881EE8066788";
/// <summary>
/// Determines if the current platform supports full pdb generation.
/// </summary>
/// <returns><c>true</c> if full pdb generation is supported; <c>false</c> otherwise.</returns>
public static bool SupportsFullPdbGeneration()
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
// Cross-plat always produce portable pdbs.
return false;
}
if (Type.GetType("Mono.Runtime") != null)
{
return false;
}
try
{
// Check for the pdb writer component that roslyn uses to generate pdbs
var type = Marshal.GetTypeFromCLSID(new Guid(SymWriterGuid));
if (type != null)
{
// This line will throw if pdb generation is not supported.
Activator.CreateInstance(type);
return true;
}
}
catch
{
}
return false;
}
}
}
|