use msbuild variable for root namespace when available

This commit is contained in:
13xforever
2021-02-13 19:45:07 +05:00
parent 029ca500b6
commit cc0d4355d5
2 changed files with 6 additions and 2 deletions

View File

@@ -6,6 +6,10 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<CompilerVisibleProperty Include="RootNamespace" />
</ItemGroup>
<ItemGroup>
<None Remove="confusables.txt" />
<AdditionalFiles Include="confusables.txt" />

View File

@@ -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;")