Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⬆️ Bump files with dotnet-file sync #35

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/os-matrix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[ "ubuntu-latest", "macOS-latest", "windows-latest" ]
24 changes: 0 additions & 24 deletions .github/workflows/sponsor.yml

This file was deleted.

5 changes: 0 additions & 5 deletions .netconfig
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,6 @@
sha = c879f25bf483086725c8a29f104555644e6ee542
etag = fcb46a86511cb7996e8dcd1f4e283cea9cd51610b094ac49a7396301730814b0
weak
[file "src/SponsorLink/Tests/Resources.Designer.cs"]
url = https://github.com/devlooped/oss/blob/main/src/SponsorLink/Tests/Resources.Designer.cs
sha = c879f25bf483086725c8a29f104555644e6ee542
etag = 69404ac09238930893fdbc225ae7839b14957e129b4c05f1ef0e7afcc4c91d63
weak
[file "src/SponsorLink/Tests/Resources.resx"]
url = https://github.com/devlooped/oss/blob/main/src/SponsorLink/Tests/Resources.resx
sha = c879f25bf483086725c8a29f104555644e6ee542
Expand Down
2 changes: 0 additions & 2 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@

<PropertyGroup Label="Build">
<Configuration Condition="'$(Configuration)' == '' and $(CI)">Release</Configuration>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<GenerateDocumentationFile Condition="$(MSBuildProjectName.Contains('Tests'))">false</GenerateDocumentationFile>
<LangVersion>Latest</LangVersion>

<!-- See https://docs.microsoft.com/en-us/dotnet/standard/assembly/reference-assemblies -->
Expand Down
7 changes: 7 additions & 0 deletions src/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
<PropertyGroup Condition="'$(CI)' == 'true' and '$(Language)' == 'C#'">
<DefineConstants>CI;$(DefineConstants)</DefineConstants>
</PropertyGroup>

<PropertyGroup Label="Build">
<!-- Tests projects don't need API docs, typically -->
<GenerateDocumentationFile Condition="$(GenerateDocumentationFile) == '' and $(IsTestProject) == 'true'">false</GenerateDocumentationFile>
<GenerateDocumentationFile Condition="$(GenerateDocumentationFile) == '' and $(MSBuildProjectName.Contains('Tests'))">false</GenerateDocumentationFile>
<GenerateDocumentationFile Condition="$(GenerateDocumentationFile) == ''">true</GenerateDocumentationFile>
</PropertyGroup>

<PropertyGroup Condition="'$(IsPackable)' == ''">
<IsPackable Condition="'$(PackAsTool)' == 'true'">true</IsPackable>
Expand Down
21 changes: 15 additions & 6 deletions src/SponsorLink/Analyzer/Analyzer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
<IsRoslynComponent>true</IsRoslynComponent>
<PackFolder>analyzers/dotnet/roslyn4.0</PackFolder>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<MergeAnalyzerAssemblies>false</MergeAnalyzerAssemblies>
<MergeAnalyzerAssemblies Condition="'$(OS)' == 'Windows_NT'">true</MergeAnalyzerAssemblies>
<CustomAfterMicrosoftCSharpTargets>$(MSBuildThisFileDirectory)..\SponsorLink.targets</CustomAfterMicrosoftCSharpTargets>
<MergeAnalyzerAssemblies>true</MergeAnalyzerAssemblies>
<ImplicitUsings>disable</ImplicitUsings>
<FundingPackageId>SponsorableLib</FundingPackageId>
</PropertyGroup>

<ItemGroup>
Expand All @@ -22,16 +24,23 @@
<PackageReference Include="ThisAssembly.Project" Version="1.4.3" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
<InternalsVisibleTo Include="Tests" />
</ItemGroup>

<ItemGroup>
<None Update="buildTransitive\SponsorableLib.targets" Pack="true" />
</ItemGroup>

<ItemGroup>
<Compile Remove="C:\Code\devlooped.oss\src\SponsorLink\SponsorLink\ThisAssembly.cs" />
<InternalsVisibleTo Include="Tests" />
</ItemGroup>

<!-- To support tests, fake an extra sponsorable with the test key -->
<Target Name="ReadTestJwk" BeforeTargets="GetAssemblyAttributes">
<PropertyGroup>
<!-- Read public key we validate manifests against -->
<TestJwk>$([System.IO.File]::ReadAllText('$(MSBuildThisFileDirectory)..\Tests\keys\kzu.pub.jwk'))</TestJwk>
</PropertyGroup>
<ItemGroup>
<AssemblyMetadata Include="Funding.GitHub.kzu" Value="$(TestJwk)" />
</ItemGroup>
</Target>

</Project>
32 changes: 26 additions & 6 deletions src/SponsorLink/Analyzer/StatusReportingAnalyzer.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,45 @@
using System.Collections.Immutable;
using System;
using System.Collections.Immutable;
using System.IO;
using System.Linq;
using Devlooped.Sponsors;
using Humanizer;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using static Devlooped.Sponsors.SponsorLink;

namespace Analyzer;

[DiagnosticAnalyzer(LanguageNames.CSharp)]
[DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)]
public class StatusReportingAnalyzer : DiagnosticAnalyzer
{
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray<DiagnosticDescriptor>.Empty;
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray.Create(new DiagnosticDescriptor(
"SL001", "Report Sponsoring Status", "Reports sponsoring status determined by SponsorLink", "Sponsors",
DiagnosticSeverity.Warning, true));

public override void Initialize(AnalysisContext context)
{
context.EnableConcurrentExecution();
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);

context.RegisterCodeBlockAction(c =>
context.RegisterCompilationAction(c =>
{
var status = Diagnostics.GetStatus(Funding.Product);
Tracing.Trace($"Status: {status}");
var installed = c.Options.AdditionalFiles.Where(x =>
{
var options = c.Options.AnalyzerConfigOptionsProvider.GetOptions(x);
// In release builds, we'll have a single such item, since we IL-merge the analyzer.
return options.TryGetValue("build_metadata.Analyzer.ItemType", out var itemType) &&
options.TryGetValue("build_metadata.Analyzer.NuGetPackageId", out var packageId) &&
itemType == "Analyzer" &&
packageId == "SponsorableLib";
}).Select(x => File.GetLastWriteTime(x.Path)).OrderByDescending(x => x).FirstOrDefault();

var status = Diagnostics.GetOrSetStatus(() => c.Options);

if (installed != default)
Tracing.Trace($"Status: {status}, Installed: {(DateTime.Now - installed).Humanize()} ago");
else
Tracing.Trace($"Status: {status}, unknown install time");
});
}
}
23 changes: 23 additions & 0 deletions src/SponsorLink/Analyzer/StatusReportingGenerator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Devlooped.Sponsors;
using Microsoft.CodeAnalysis;
using static Devlooped.Sponsors.SponsorLink;

namespace Analyzer;

[Generator]
public class StatusReportingGenerator : IIncrementalGenerator
{
public void Initialize(IncrementalGeneratorInitializationContext context)
{
context.RegisterSourceOutput(
// this is required to ensure status is registered properly independently
// of analyzer runs.
context.GetSponsorAdditionalFiles().Combine(context.AnalyzerConfigOptionsProvider),
(spc, source) =>
{
var (manifests, options) = source;
var status = Diagnostics.GetOrSetStatus(manifests, options);
spc.AddSource("StatusReporting.cs", $"// Status: {status}");
});
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="Devlooped.Sponsors.targets"/>
<ItemGroup>
<!-- Brings in the analyzer file to report installation time -->
<FundingPackageId Include="SponsorableLib" />
</ItemGroup>
</Project>
4 changes: 4 additions & 0 deletions src/SponsorLink/Library/Library.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@
<ProjectReference Include="..\Analyzer\Analyzer.csproj" ReferenceOutputAssembly="false" OutputType="Analyzer" />
</ItemGroup>

<Target Name="Version" AfterTargets="GetPackageContents" DependsOnTargets="GetPackageTargetPath">
<Message Importance="high" Text="$(MSBuildProjectName) &gt; $(PackageTargetPath)" />
</Target>

</Project>
4 changes: 2 additions & 2 deletions src/SponsorLink/SponsorLink.Tests.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

<ItemGroup Condition="'$(ManagePackageVersionsCentrally)' == 'true'">
<PackageReference Include="Humanizer.Core" VersionOverride="2.14.1" PrivateAssets="all" Pack="false" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" VersionOverride="7.6.0" PrivateAssets="all" Pack="false" />
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="7.6.2" PrivateAssets="all" Pack="false" />
</ItemGroup>

<ItemGroup Condition="'$(ManagePackageVersionsCentrally)' != 'true'">
<PackageReference Include="Humanizer.Core" Version="2.14.1" PrivateAssets="all" Pack="false" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.6.0" PrivateAssets="all" Pack="false" />
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="7.6.2" PrivateAssets="all" Pack="false" />
</ItemGroup>

<Target Name="AddSponsorLinkAnalyzerDependencies" BeforeTargets="CoreCompile" DependsOnTargets="ResolveLockFileCopyLocalFiles">
Expand Down
33 changes: 25 additions & 8 deletions src/SponsorLink/SponsorLink.targets
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@
<PropertyGroup>
<ShowSponsorLinkInProject Condition="$(ShowSponsorLinkInProject) == '' and '$(TargetFramework)' == 'netstandard2.0'">true</ShowSponsorLinkInProject>
<!-- This ensures we expose only the main assembly in the Dependencies > Analyzers node -->
<MergeAnalyzerAssemblies Condition="'$(MergeAnalyzerAssemblies)' == '' and '$(Configuration)' == 'Release'">true</MergeAnalyzerAssemblies>
<MergeAnalyzerAssemblies Condition="'$(MergeAnalyzerAssemblies)' == '' and '$(Configuration)' == 'Release' and '$(OS)' == 'Windows_NT'">true</MergeAnalyzerAssemblies>
<MergeAnalyzerAssemblies Condition="'$(MergeAnalyzerAssemblies)' == ''">false</MergeAnalyzerAssemblies>
<!-- Whether we merge files or not, dependencies will need to be copy-local -->
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<!-- Make Resources visible to intellisense -->
<CoreCompileDependsOn>CoreResGen;$(CoreCompileDependsOn)</CoreCompileDependsOn>

<!-- Default funding product the Product, which already part of ThisAssembly -->
<FundingProduct Condition="'$(FundingProduct)' == ''">$(Product)</FundingProduct>
<FundingPackageId Condition="'$(FundingPackageId)' == ''">$(PackageId)</FundingPackageId>
<!-- Default prefix is the joined upper-case letters in the product name (i.e. for ThisAssembly, TA) -->
<FundingPrefix Condition="'$(FundingPrefix)' == ''">$([System.Text.RegularExpressions.Regex]::Replace("$(FundingProduct)", "[^A-Z]", ""))</FundingPrefix>
<!-- Default grace days for an expired sponsor manifest -->
<FundingGrace Condition="'$(FundingGrace)' == ''">21</FundingGrace>
<!-- Default grace days for an expired sponsor manifest or unknown status -->
<FundingGrace Condition="'$(FundingGrace)' == ''">15</FundingGrace>
</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -68,28 +70,38 @@
</None>
</ItemGroup>

<PropertyGroup>
<PackMergedAssemblies>true</PackMergedAssemblies>
<PackMergedAssemblies Condition="'$(MergeAnalyzerAssemblies)' == 'true'">false</PackMergedAssemblies>
</PropertyGroup>

<ItemGroup Condition="'$(ManagePackageVersionsCentrally)' == 'true'">
<PackageReference Include="Humanizer.Core" VersionOverride="2.14.1" PrivateAssets="all" Pack="false" />
<PackageReference Include="Humanizer.Core" VersionOverride="2.14.1" PrivateAssets="all" Pack="$(PackMergedAssemblies)" />
<PackageReference Include="Humanizer.Core.es" VersionOverride="2.14.1" PrivateAssets="all" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" VersionOverride="7.6.0" PrivateAssets="all" Pack="false" />
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" VersionOverride="7.6.2" PrivateAssets="all" Pack="$(PackMergedAssemblies)" />
<PackageReference Include="ILRepack" Version="2.0.33" VersionOverride="all" PrivateAssets="all" Pack="false" />
</ItemGroup>

<ItemGroup Condition="'$(ManagePackageVersionsCentrally)' != 'true'">
<PackageReference Include="Humanizer.Core" Version="2.14.1" PrivateAssets="all" Pack="false" />
<PackageReference Include="Humanizer.Core" Version="2.14.1" PrivateAssets="all" Pack="$(PackMergedAssemblies)" />
<PackageReference Include="Humanizer.Core.es" Version="2.14.1" PrivateAssets="all" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.6.0" PrivateAssets="all" Pack="false" />
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="7.6.2" PrivateAssets="all" Pack="$(PackMergedAssemblies)" />
<PackageReference Include="ILRepack" Version="2.0.33" PrivateAssets="all" Pack="false" />
</ItemGroup>

<Target Name="EmitFunding" BeforeTargets="GenerateMSBuildEditorConfigFileShouldRun" Inputs="$(MSBuildAllProjects)" Outputs="$(IntermediateOutputPath)SponsorLink.g.cs">
<Target Name="EmitFunding" BeforeTargets="CompileDesignTime;CoreCompile" Inputs="$(MSBuildAllProjects)" Outputs="$(IntermediateOutputPath)SponsorLink.g.cs">
<Warning Condition="'$(FundingPackageId)' == ''" Code="SL001"
Text="Could not determine value of FundingPackageId (defaulted to PackageId). Defaulting it to FundingProduct ('$(FundingProduct)'). Make sure this matches the containing package id, or set an explicit value." />
<PropertyGroup>
<!-- Default to Product, which is most common for single-package products (i.e. Moq) -->
<FundingPackageId Condition="'$(FundingPackageId)' == ''">$(FundingProduct)</FundingPackageId>
<SponsorLinkPartial>namespace Devlooped.Sponsors%3B

partial class SponsorLink
{
public partial class Funding
{
public const string PackageId = "$(FundingPackageId)"%3B
public const string Product = "$(FundingProduct)"%3B
public const string Prefix = "$(FundingPrefix)"%3B
public const int Grace = $(FundingGrace)%3B
Expand Down Expand Up @@ -183,4 +195,9 @@ partial class SponsorLink
</ItemGroup>
</Target>

<PropertyGroup>
<!-- Can be used in analyzer projects to detect double imports -->
<SponsorLinkImported>true</SponsorLinkImported>
</PropertyGroup>

</Project>
Loading