-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# devlooped/oss - Dynamically fetch devlooped JWK from github devlooped/oss@55124bc - Add targets for inclusion from tests devlooped/oss@81ba912 - Remove dependency on ThisAssembly devlooped/oss@c879f25 - Fix path to jwk.ps1 alongside the SponsorLink.targets devlooped/oss@c4830fc - SponsorLink code should be checked as regular code devlooped/oss@e81ab75 - Minor code simplification devlooped/oss@cf154d5 - Update to newest JsonWebTokens devlooped/oss@068140b - Rename sample assemblies for nicer display devlooped/oss@93df7c7 - Fix scenario where multiple packages share product name devlooped/oss@23f83bd - Switch to built-in item metadata for manifest analyzer files devlooped/oss@49c9a38 - Add support and showcase determining install time devlooped/oss@717ddb1 - Improve versioning of sample package devlooped/oss@3b943f5 - Change debug traces location to the well-known location of .sponsorlink devlooped/oss@1019e2a - Revert back to dotnet-sponsor devlooped/oss@8d29f01 - SponsorLink-enabled analyzers need copylocal devlooped/oss@7593657
- Loading branch information
1 parent
adfc77d
commit 87cc02f
Showing
29 changed files
with
605 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,44 @@ | ||
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; | ||
using static ThisAssembly.Constants; | ||
|
||
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 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.GetStatus(Funding.Product); | ||
Tracing.Trace($"Status: {status}"); | ||
if (installed != default) | ||
Tracing.Trace($"Status: {status}, Installed: {(DateTime.Now - installed).Humanize()} ago"); | ||
else | ||
Tracing.Trace($"Status: {status}, unknown install time"); | ||
}); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
src/SponsorLink/Analyzer/buildTransitive/SponsorableLib.targets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 --> | ||
<SponsorablePackageId Include="SponsorableLib" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Sponsorable Library | ||
|
||
Example of a library that is available for sponsorship and leverages | ||
[SponsorLink](https://github.com/devlooped/SponsorLink) to remind users | ||
in an IDE (VS/Rider). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<Project> | ||
<!-- For inclusion in test projects that reference analyzers as project references --> | ||
|
||
<PropertyGroup> | ||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> | ||
</PropertyGroup> | ||
|
||
<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" /> | ||
</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" /> | ||
</ItemGroup> | ||
|
||
<Target Name="AddSponsorLinkAnalyzerDependencies" BeforeTargets="CoreCompile" DependsOnTargets="ResolveLockFileCopyLocalFiles"> | ||
<ItemGroup> | ||
<!-- NOTE: keep in sync with ILRepack'ed assemblies as needed --> | ||
<ReferenceCopyLocalAssemblies Include="@(ReferenceCopyLocalPaths)" Condition="'%(Extension)' == '.dll' | ||
And !$([MSBuild]::ValueOrDefault('%(FileName)', '').EndsWith('.resources', StringComparison.OrdinalIgnoreCase)) | ||
And !$([MSBuild]::ValueOrDefault('%(FileName)', '').StartsWith('ThisAssembly', StringComparison.OrdinalIgnoreCase))" /> | ||
<Analyzer Include="@(ReferenceCopyLocalAssemblies)" Condition=" | ||
!$([MSBuild]::ValueOrDefault('%(FileName)', '').StartsWith('Microsoft.CodeAnalysis', StringComparison.OrdinalIgnoreCase)) And | ||
!$([MSBuild]::ValueOrDefault('%(FileName)', '').StartsWith('Microsoft.CSharp', StringComparison.OrdinalIgnoreCase)) And | ||
!$([MSBuild]::ValueOrDefault('%(FileName)', '').StartsWith('System.', StringComparison.OrdinalIgnoreCase))" | ||
/> | ||
<!-- Brings in System/Microsoft.IdentityModel, System.Text.Encodings.Web, System.Text.Json --> | ||
<Analyzer Include="@(ReferenceCopyLocalAssemblies)" Condition=" | ||
$([MSBuild]::ValueOrDefault('%(FileName)', '').StartsWith('System.IdentityModel', StringComparison.OrdinalIgnoreCase)) Or | ||
$([MSBuild]::ValueOrDefault('%(FileName)', '').StartsWith('Microsoft.IdentityModel', StringComparison.OrdinalIgnoreCase)) Or | ||
$([MSBuild]::ValueOrDefault('%(FileName)', '').StartsWith('System.Text', StringComparison.OrdinalIgnoreCase))" | ||
/> | ||
</ItemGroup> | ||
</Target> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.