diff --git a/.gitignore b/.gitignore index 940794e..ccfa9bd 100644 --- a/.gitignore +++ b/.gitignore @@ -286,3 +286,5 @@ __pycache__/ *.btm.cs *.odx.cs *.xsd.cs + +*.binlog diff --git a/README.md b/README.md index 0e23392..0356082 100644 --- a/README.md +++ b/README.md @@ -13,12 +13,13 @@ Just add the package and define the `InternalsAssemblyNames` property with a sem ```xml - - AssemblyToGrantAccessTo1;AssemblyToGrantAccessTo2 - + + + + - + diff --git a/src/Build/IgnoresAccessChecksToGenerator.props b/src/Build/IgnoresAccessChecksToGenerator.props new file mode 100644 index 0000000..e09bbb2 --- /dev/null +++ b/src/Build/IgnoresAccessChecksToGenerator.props @@ -0,0 +1,9 @@ + + + + + false + + + + diff --git a/src/Build/IgnoresAccessChecksToGenerator.targets b/src/Build/IgnoresAccessChecksToGenerator.targets index fde972c..0e90059 100644 --- a/src/Build/IgnoresAccessChecksToGenerator.targets +++ b/src/Build/IgnoresAccessChecksToGenerator.targets @@ -1,27 +1,34 @@ - <_IACTG_TFM Condition="'$(MSBuildRuntimeType)' == 'Core'">netstandard2.0 - <_IACTG_TFM Condition="'$(MSBuildRuntimeType)' != 'Core'">net46 - <_IACTG_TaskAssembly>$(MSBuildThisFileDirectory)..\tools\$(_IACTG_TFM)\IgnoresAccessChecksToGenerator.Tasks.dll + <_IACTG_TargetFramework Condition="'$(MSBuildRuntimeType)' == 'Core'">netstandard2.0 + <_IACTG_TargetFramework Condition="'$(MSBuildRuntimeType)' != 'Core'">net46 + <_IACTG_TaskAssembly>$(MSBuildThisFileDirectory)..\tools\$(_IACTG_TargetFramework)\IgnoresAccessChecksToGenerator.Tasks.dll + <_IACTG_IntermediatePath>$(IntermediateOutputPath)/GeneratedPublicizedAssemblies - + - - + + + + + + + + + <_IACTG_Directory Include="$(_IACTG_IntermediatePath)" /> + + + + diff --git a/src/IgnoresAccessChecksToGenerator.Tasks/IgnoresAccessChecksToGenerator.nuspec b/src/IgnoresAccessChecksToGenerator.Tasks/IgnoresAccessChecksToGenerator.nuspec index c5f88a4..be0f21b 100644 --- a/src/IgnoresAccessChecksToGenerator.Tasks/IgnoresAccessChecksToGenerator.nuspec +++ b/src/IgnoresAccessChecksToGenerator.Tasks/IgnoresAccessChecksToGenerator.nuspec @@ -2,7 +2,7 @@ IgnoresAccessChecksToGenerator - 0.5.0 + 0.6.0 aelij aelij MIT @@ -10,7 +10,7 @@ false Generates IgnoresAccessChecksTo attributes and reference assemblies to allow compile-time access to internals - Copyright 2021 + Copyright 2022 IgnoresAccessChecksToGenerator internals diff --git a/src/IgnoresAccessChecksToGenerator.Tasks/PublicizeInternals.cs b/src/IgnoresAccessChecksToGenerator.Tasks/PublicizeInternals.cs index 1e180eb..67daf77 100644 --- a/src/IgnoresAccessChecksToGenerator.Tasks/PublicizeInternals.cs +++ b/src/IgnoresAccessChecksToGenerator.Tasks/PublicizeInternals.cs @@ -18,10 +18,10 @@ public class PublicizeInternals : Task public ITaskItem[] SourceReferences { get; set; } [Required] - public string AssemblyNames { get; set; } + public ITaskItem[] AssemblyNames { get; set; } [Required] - public string IntermediateOutputDirectory { get; set; } + public string IntermediateOutputPath { get; set; } public string ExcludeTypeNames { get; set; } @@ -40,22 +40,20 @@ public override bool Execute() { if (SourceReferences == null) throw new ArgumentNullException(nameof(SourceReferences)); - var assemblyNames = new HashSet( - (AssemblyNames ?? string.Empty).Split(Semicolon, StringSplitOptions.RemoveEmptyEntries), - StringComparer.OrdinalIgnoreCase); + var assemblyNames = new HashSet(AssemblyNames.Select(t => t.ItemSpec), StringComparer.OrdinalIgnoreCase); if (assemblyNames.Count == 0) { return true; } - var targetPath = Path.Combine(IntermediateOutputDirectory, "GeneratedPublicizedAssemblies"); + var targetPath = IntermediateOutputPath; Directory.CreateDirectory(targetPath); GenerateAttributes(targetPath, assemblyNames); foreach (var assemblyPath in SourceReferences - .Select(a => Path.GetDirectoryName(GetFullFilePath(a.ItemSpec)))) + .Select(a => Path.GetDirectoryName(GetFullFilePath(targetPath, a.ItemSpec)))) { _resolver.AddSearchDirectory(assemblyPath); } @@ -65,7 +63,7 @@ public override bool Execute() foreach (var assembly in SourceReferences) { - var assemblyPath = GetFullFilePath(assembly.ItemSpec); + var assemblyPath = GetFullFilePath(targetPath, assembly.ItemSpec); var assemblyName = Path.GetFileNameWithoutExtension(assemblyPath); if (assemblyNames.Contains(assemblyName)) { @@ -174,11 +172,8 @@ private void CreatePublicAssembly(string source, string target) assembly.Write(target); } - private string GetFullFilePath(string path) - { - path = Path.GetFullPath(path); - return path; - } + private string GetFullFilePath(string basePath, string path) => + Path.IsPathRooted(path) ? Path.GetFullPath(path) : Path.Combine(basePath, path); private class AssemblyResolver : IAssemblyResolver { diff --git a/src/IgnoresAccessChecksToGenerator.sln b/src/IgnoresAccessChecksToGenerator.sln index e90cb31..fd74240 100644 --- a/src/IgnoresAccessChecksToGenerator.sln +++ b/src/IgnoresAccessChecksToGenerator.sln @@ -1,20 +1,16 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26430.16 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33103.201 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IgnoresAccessChecksToGenerator.Tasks", "IgnoresAccessChecksToGenerator.Tasks\IgnoresAccessChecksToGenerator.Tasks.csproj", "{FFFAEEE5-E216-442C-9162-168AD30F57F5}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{D43D3D13-84B1-4D21-8E36-52BED4056097}" ProjectSection(SolutionItems) = preProject + Build\IgnoresAccessChecksToGenerator.props = Build\IgnoresAccessChecksToGenerator.props Build\IgnoresAccessChecksToGenerator.targets = Build\IgnoresAccessChecksToGenerator.targets EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuGet", "NuGet", "{1CD3690D-3079-4F56-B140-036590665068}" - ProjectSection(SolutionItems) = preProject - IgnoresAccessChecksToGenerator.nuspec = IgnoresAccessChecksToGenerator.nuspec - EndProjectSection -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -29,4 +25,7 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {93618651-EC7C-40FD-9683-C87FEC4A4947} + EndGlobalSection EndGlobal diff --git a/test/IgnoresAccessChecksToGenerator.Test/IgnoresAccessChecksToGenerator.Test.csproj b/test/IgnoresAccessChecksToGenerator.Test/IgnoresAccessChecksToGenerator.Test.csproj index a0663e3..ff97f01 100644 --- a/test/IgnoresAccessChecksToGenerator.Test/IgnoresAccessChecksToGenerator.Test.csproj +++ b/test/IgnoresAccessChecksToGenerator.Test/IgnoresAccessChecksToGenerator.Test.csproj @@ -1,12 +1,16 @@  - netcoreapp3.1 + net6.0 Exe - Microsoft.CodeAnalysis;Microsoft.CodeAnalysis.CSharp false + + + + +