-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an easy way to check for design-time builds
- Loading branch information
Showing
2 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Microsoft.CodeAnalysis.Diagnostics; | ||
|
||
static class AnalyzerOptionsExtensions | ||
{ | ||
/// <summary> | ||
/// Gets whether the current build is a design-time build. | ||
/// </summary> | ||
public static bool IsDesignTimeBuild(this AnalyzerConfigOptionsProvider options) => | ||
options.GlobalOptions.TryGetValue("build_property.DesignTimeBuild", out var value) && | ||
bool.TryParse(value, out var isDesignTime) && isDesignTime; | ||
|
||
/// <summary> | ||
/// Gets whether the current build is a design-time build. | ||
/// </summary> | ||
public static bool IsDesignTimeBuild(this AnalyzerConfigOptions options) => | ||
options.TryGetValue("build_property.DesignTimeBuild", out var value) && | ||
bool.TryParse(value, out var isDesignTime) && isDesignTime; | ||
} |