Skip to content

Commit f9f356d

Browse files
committed
Cleaned up code, fixed unit tests, removed extra project foor Attributes
1 parent 61fe249 commit f9f356d

File tree

63 files changed

+7
-170
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+7
-170
lines changed

build/ApplicationBuildConfigs.cs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,3 @@ public static SourceGeneratorProjectPaths LoadFromContext(ICakeContext context,
3636
nugetFilePath);
3737
}
3838
};
39-
40-
public record AttributesProjectPaths(
41-
string ProjectName,
42-
string ProjectFolder,
43-
string CsprojFile,
44-
string OutDir,
45-
string NuGetFilePath)
46-
{
47-
public static AttributesProjectPaths LoadFromContext(ICakeContext context, string buildConfiguration, string srcDirectory, string nugetVersion)
48-
{
49-
var projectName = "PublicInterfaceGenerator.Attributes";
50-
var projectDir = srcDirectory + $"/{projectName}";
51-
var csProjFile = projectDir + $"/{projectName}.csproj";
52-
var outDir = projectDir + $"/bin/{buildConfiguration}/cake-build-output/attributes";
53-
var nugetFilePath = outDir + $"/*{nugetVersion}.nupkg";
54-
55-
return new AttributesProjectPaths(
56-
projectName,
57-
projectDir,
58-
csProjFile,
59-
outDir,
60-
nugetFilePath);
61-
}
62-
};

build/Program.cs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ public class BuildContext : FrostingContext
3232
public bool PushNuget { get; }
3333
public string NuGetPushToken { get; }
3434
public SourceGeneratorProjectPaths SourceGeneratorProjectPaths { get; }
35-
public AttributesProjectPaths AttributesProjectPaths { get; }
36-
3735
public BuildContext(ICakeContext context)
3836
: base(context)
3937
{
@@ -44,7 +42,6 @@ public BuildContext(ICakeContext context)
4442
PushNuget = context.Argument<bool>("pushNuget", false);
4543

4644
SourceGeneratorProjectPaths = SourceGeneratorProjectPaths.LoadFromContext(context, BuildConfiguration, SrcDirectoryPath, NugetVersion);
47-
AttributesProjectPaths = AttributesProjectPaths.LoadFromContext(context, BuildConfiguration, SrcDirectoryPath, NugetVersion);
4845
}
4946

5047
private string LoadParameter(ICakeContext context, string parameterName)
@@ -62,7 +59,6 @@ public override void Run(BuildContext context)
6259

6360
context.Log.Information($"INFO: {nameof(context.SrcDirectoryPath)}: {context.SrcDirectoryPath}");
6461
context.Log.Information($"INFO: {nameof(context.SourceGeneratorProjectPaths)}.{nameof(context.SourceGeneratorProjectPaths.ProjectName)}: {context.SourceGeneratorProjectPaths.ProjectName}");
65-
context.Log.Information($"INFO: {nameof(context.SourceGeneratorProjectPaths)}.{nameof(context.AttributesProjectPaths.ProjectName)}: {context.AttributesProjectPaths.ProjectName}");
6662
}
6763
}
6864

@@ -77,7 +73,6 @@ public override void Run(BuildContext context)
7773
BuildDotnetApp(context, context.SourceGeneratorProjectPaths.PathToSln);
7874
TestDotnetApp(context, context.SourceGeneratorProjectPaths.UnitTestProj);
7975
PackNugetPackage(context, context.SourceGeneratorProjectPaths.OutDir, context.SourceGeneratorProjectPaths.CsprojFile);
80-
PackNugetPackage(context, context.AttributesProjectPaths.OutDir, context.AttributesProjectPaths.CsprojFile);
8176
}
8277

8378
private void BuildDotnetApp(BuildContext context, string pathToSln)
@@ -99,8 +94,8 @@ private void TestDotnetApp(BuildContext context, string pathToUnitTestProj)
9994
NoBuild = true,
10095
ArgumentCustomization = (args) => args.Append("/p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --logger trx")
10196
};
102-
103-
//context.DotNetTest(pathToUnitTestProj, testSettings);
97+
98+
context.DotNetTest(pathToUnitTestProj, testSettings);
10499
}
105100

106101
private void PackNugetPackage(BuildContext context, string outDir, string csprojFile)
@@ -134,12 +129,6 @@ public override void Run(BuildContext context)
134129
Source = "https://api.nuget.org/v3/index.json",
135130
ApiKey = context.NuGetPushToken
136131
});
137-
138-
context.DotNetNuGetPush(context.AttributesProjectPaths.NuGetFilePath, new Cake.Common.Tools.DotNet.NuGet.Push.DotNetNuGetPushSettings
139-
{
140-
Source = "https://api.nuget.org/v3/index.json",
141-
ApiKey = context.NuGetPushToken
142-
});
143132
}
144133
}
145134

samples/Samples/Samples.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@
88

99
<ItemGroup>
1010
<ProjectReference Include="..\..\src\PublicInterfaceGenerator\PublicInterfaceGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
11-
<!--<ProjectReference Include="..\..\src\PublicInterfaceGenerator.Attributes\PublicInterfaceGenerator.Attributes.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="true" />-->
1211
</ItemGroup>
1312
</Project>

src/PublicInterfaceGenerator.Attributes/ExcludeFromGeneratedInterfaceAttribute.cs

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/PublicInterfaceGenerator.Attributes/GenerateInterfaceAttribute.cs

Lines changed: 0 additions & 62 deletions
This file was deleted.

src/PublicInterfaceGenerator.Attributes/PublicInterfaceGenerator.Attributes.csproj

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/PublicInterfaceGenerator.sln

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{A7E17D8D
99
EndProject
1010
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Examples", "Examples", "{7235A503-C7CD-4028-88F4-15DBD7371471}"
1111
EndProject
12-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PublicInterfaceGenerator.Attributes", "PublicInterfaceGenerator.Attributes\PublicInterfaceGenerator.Attributes.csproj", "{59953E27-6190-44CE-9244-DBA1566811F5}"
13-
EndProject
1412
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples", "..\samples\Samples\Samples.csproj", "{2CD3B72B-1597-471F-AE24-1D7D6340A324}"
1513
EndProject
1614
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTests", "UnitTests\UnitTests.csproj", "{C15212B0-08B0-401D-A7BD-B340DE194195}"
@@ -29,10 +27,6 @@ Global
2927
{0B2D223E-3D20-4A06-9CFE-F7CC8C450552}.Debug|Any CPU.Build.0 = Debug|Any CPU
3028
{0B2D223E-3D20-4A06-9CFE-F7CC8C450552}.Release|Any CPU.ActiveCfg = Release|Any CPU
3129
{0B2D223E-3D20-4A06-9CFE-F7CC8C450552}.Release|Any CPU.Build.0 = Release|Any CPU
32-
{59953E27-6190-44CE-9244-DBA1566811F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33-
{59953E27-6190-44CE-9244-DBA1566811F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
34-
{59953E27-6190-44CE-9244-DBA1566811F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
35-
{59953E27-6190-44CE-9244-DBA1566811F5}.Release|Any CPU.Build.0 = Release|Any CPU
3630
{2CD3B72B-1597-471F-AE24-1D7D6340A324}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
3731
{2CD3B72B-1597-471F-AE24-1D7D6340A324}.Debug|Any CPU.Build.0 = Debug|Any CPU
3832
{2CD3B72B-1597-471F-AE24-1D7D6340A324}.Release|Any CPU.ActiveCfg = Release|Any CPU

src/PublicInterfaceGenerator/AttributeGenerationHelper.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ public static string GenerateAttributesCode()
1818
return builder.ToString();
1919
}
2020

21+
/// <summary>
22+
/// Creates the Microsoft.CodeAnalysis.EmbeddedAttribute
23+
/// This is a special attribute the compiler knows about. This allows us to have the same attribute defined in multiple assemblies in a project
24+
/// We care about that when a user has multiple projects in a solution and they are using this source generator in each one, meaning the GenerateInterfaceAttribute will be defined in each of their projects
25+
/// </summary>
2126
public static string GenerateEmbeddedAttribute()
2227
{
2328
return

src/PublicInterfaceGenerator/PublicInterfaceGenerator.csproj

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -38,38 +38,13 @@
3838
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.13.0" PrivateAssets="all" />
3939
</ItemGroup>
4040

41-
<!--<ItemGroup>
42-
<PackageReference Include="ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes" Version="*" GeneratePathProperty="true" PrivateAssets="all" />
43-
</ItemGroup>-->
44-
<!-- Reference the attributes from the generator to compile against them -->
45-
<!-- Ensure we specify PrivateAssets so the NuGet doesn't have any dependencies -->
46-
<!--<ItemGroup>
47-
<ProjectReference Include="..\PublicInterfaceGenerator.Attributes\PublicInterfaceGenerator.Attributes.csproj" PrivateAssets="All" />
48-
</ItemGroup>-->
49-
5041
<ItemGroup>
51-
<!-- Anyone using the generator needs to use the attributes NuGet so any reflection doesn't throw when it sees the attributes in code -->
52-
<!--<PackageReference Include="ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes" Version="1.*" />-->
53-
5442
<!-- Package the generator in the analyzer directory of the nuget package -->
5543
<None Include="$(OutputPath)/$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
5644

57-
<!--Pack the attributes dll in the lib\netstandard2.0 path so the library consuming this nuget can use it-->
58-
<!--<None Include="$(OutputPath)/ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes.dll" Pack="true" PackagePath="lib/netstandard2.0" Visible="false" />-->
59-
6045
<None Include="../../README.md" Pack="true" PackagePath="/" />
6146
</ItemGroup>
6247

63-
<!--<PropertyGroup>
64-
<GetTargetPathDependsOn>$(GetTargetPathDependsOn);GetDependencyTargetPaths</GetTargetPathDependsOn>
65-
</PropertyGroup>
66-
67-
<Target Name="GetDependencyTargetPaths">
68-
<ItemGroup>
69-
<TargetPathWithTargetPlatformMoniker Include="$(PKGProgrammerAl_SourceGenerators_PublicInterfaceGenerator_Attributes)\lib\netstandard2.0\ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes.dll" IncludeRuntimeDependency="false" />
70-
</ItemGroup>
71-
</Target>-->
72-
7348
<PropertyGroup>
7449
<NuGetAudit>true</NuGetAudit>
7550
<NuGetAuditMode>all</NuGetAuditMode>

0 commit comments

Comments
 (0)