From cc0d4355d54d17767673122965f705d0e8c902fd Mon Sep 17 00:00:00 2001 From: 13xforever Date: Sat, 13 Feb 2021 19:45:07 +0500 Subject: [PATCH] use msbuild variable for root namespace when available --- HomoglyphConverter/HomoglyphConverter.csproj | 4 ++++ SourceGenerators/ConfusablesSourceGenerator.cs | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/HomoglyphConverter/HomoglyphConverter.csproj b/HomoglyphConverter/HomoglyphConverter.csproj index 7cc0b375..bb62afe7 100644 --- a/HomoglyphConverter/HomoglyphConverter.csproj +++ b/HomoglyphConverter/HomoglyphConverter.csproj @@ -6,6 +6,10 @@ enable + + + + diff --git a/SourceGenerators/ConfusablesSourceGenerator.cs b/SourceGenerators/ConfusablesSourceGenerator.cs index 401c5cb5..c104482a 100644 --- a/SourceGenerators/ConfusablesSourceGenerator.cs +++ b/SourceGenerators/ConfusablesSourceGenerator.cs @@ -91,7 +91,8 @@ namespace SourceGenerators if (mapping.Count == 0) throw new InvalidOperationException("Empty confusable mapping source"); - var ns = context.Compilation.AssemblyName; + if (!context.AnalyzerConfigOptions.GlobalOptions.TryGetValue("build_property.RootNamespace", out var ns)) + ns = context.Compilation.AssemblyName; var cn = Path.GetFileNameWithoutExtension(resourceName.Path); if (cn.Length == 1) cn = cn.ToUpper(); @@ -100,7 +101,6 @@ namespace SourceGenerators if (!Version.TryParse(version, out _)) version = ""; - var result = new StringBuilder() .AppendLine("using System;") .AppendLine("using System.Collections.Generic;")