Skip to content

Commit df4740c

Browse files
committed
Add PackageReadme + Package release notes
1 parent d23aacd commit df4740c

9 files changed

+101
-12
lines changed

Generate-ReleaseNotes.bat

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
rem https://github.com/StefH/GitHubReleaseNotes
2+
3+
SET version=0.0.10
4+
5+
GitHubReleaseNotes --output "ReleaseNotes.md" --skip-empty-releases --exclude-labels question invalid doc --version %version%
6+
7+
GitHubReleaseNotes --output PackageReleaseNotes.txt --skip-empty-releases --exclude-labels question invalid doc --template PackageReleaseNotes.template --version %version%

GitHubReleaseNotes.txt

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

PackageReadme.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Usage
2+
3+
**Given: an external existing class which does not implement an interface**
4+
``` c#
5+
public sealed class Person
6+
{
7+
public string Name { get; set; }
8+
9+
public string HelloWorld(string name)
10+
{
11+
return $"Hello {name} !";
12+
}
13+
}
14+
```
15+
16+
**Create a partial interface**
17+
And annotate this with `ProxyInterfaceGenerator.Proxy[...]` and with the Type which needs to be wrapped:
18+
19+
``` c#
20+
[ProxyInterfaceGenerator.Proxy(typeof(ProxyInterfaceConsumer.Person))]
21+
public partial interface IPerson
22+
{
23+
}
24+
```
25+
26+
When the code is compiled, this source generator creates the following two items:
27+
28+
**1. An additional partial interface**
29+
Which defines the same properties and methods as in the external class.
30+
``` c#
31+
public partial interface IPerson
32+
{
33+
string Name { get; set; }
34+
35+
string HelloWorld(string name);
36+
}
37+
```
38+
39+
**2. A Proxy class**
40+
Which takes the external class in the constructor and wraps all properties and methods.
41+
42+
``` c#
43+
public class PersonProxy : IPerson
44+
{
45+
public Person _Instance { get; }
46+
47+
public PersonProxy(Person instance)
48+
{
49+
_Instance = instance;
50+
}
51+
52+
public string Name { get => _Instance.Name; set => _Instance.Name = value; }
53+
54+
public string HelloWorld(string name)
55+
{
56+
string name_ = name;
57+
var result_19479959 = _Instance.HelloWorld(name_);
58+
return result_19479959;
59+
}
60+
}
61+
```
62+
63+
## Use it
64+
``` c#
65+
IPerson p = new PersonProxy(new Person());
66+
p.Name = "test";
67+
p.HelloWorld("stef");
68+
```

PackageReleaseNotes.template

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# {{releaseInfos.0.FriendlyName}} ({{formatDate releaseInfos.0.When "dd MMMM yyyy"}})
2+
{{#each releaseInfos.0.issueInfos}}
3+
- #{{Number}} {{Title}}{{#if Labels}} [{{join Labels ", "}}]{{/if}}
4+
{{/each}}
5+
6+
The full release notes can be found here: https://github.com/StefH/ProxyInterfaceSourceGenerator/blob/main/ReleaseNotes.md

PackageReleaseNotes.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# 0.0.10 (06 August 2021)
2+
- #25 Fix support for Nullable (language version 8) [bug]
3+
- #14 for projects where #nullable is disabled emitting nullable reftype without preprocessor '#nullable enable' would result in compile time error. [bug]
4+
5+
The full release notes can be found here: https://github.com/StefH/ProxyInterfaceSourceGenerator/blob/main/ReleaseNotes.md

ProxyInterfaceSourceGenerator Solution.sln

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ EndProject
88
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2CE637DC-E8F5-4603-8B57-E51A32F631F1}"
99
ProjectSection(SolutionItems) = preProject
1010
.editorconfig = .editorconfig
11-
GitHubReleaseNotes.txt = GitHubReleaseNotes.txt
11+
Generate-ReleaseNotes.bat = Generate-ReleaseNotes.bat
12+
PackageReadme.md = PackageReadme.md
13+
PackageReleaseNotes.template = PackageReleaseNotes.template
14+
PackageReleaseNotes.txt = PackageReleaseNotes.txt
1215
README.md = README.md
1316
ReleaseNotes.md = ReleaseNotes.md
1417
EndProjectSection

src/ProxyInterfaceSourceGenerator/Context.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ internal record Context
1111

1212
// public List<ContextData> GeneratedData { get; } = new List<ContextData>();
1313

14-
public IDictionary<InterfaceDeclarationSyntax, ProxyData> CandidateInterfaces { get; init; }
14+
public IDictionary<InterfaceDeclarationSyntax, ProxyData> CandidateInterfaces { get; init; } = default!;
1515

1616
public Dictionary<string, string> ReplacedTypes { get; } = new Dictionary<string, string>();
1717
}

src/ProxyInterfaceSourceGenerator/ContextData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ internal record ContextData
88

99
public string? ClassName { get; init; }
1010

11-
public FileData FileData { get; init; }
11+
public FileData FileData { get; init; } = default!;
1212
}
1313
}

src/ProxyInterfaceSourceGenerator/ProxyInterfaceSourceGenerator.csproj

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<Version>0.0.10</Version>
4+
<Version>0.0.10-preview-01</Version>
55
<TargetFramework>netstandard2.0</TargetFramework>
6+
<ProjectGuid>{12344228-91F4-4502-9595-39584E5ABB34}</ProjectGuid>
67
<LangVersion>9</LangVersion>
78
<Nullable>enable</Nullable>
89
<Authors>Stef Heyenrath</Authors>
@@ -13,13 +14,11 @@
1314
<PackageTags>class;interface;proxy;SourceGenerator;Analyzer;Generation;Generate;wrap</PackageTags>
1415

1516
<PackageLicenseExpression>MIT</PackageLicenseExpression>
16-
<PackageReleaseNotes>See ReleaseNotes.md</PackageReleaseNotes>
17+
<PackageReleaseNotes>$([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/../../PackageReleaseNotes.txt"))</PackageReleaseNotes>
1718
<PackageProjectUrl>https://github.com/StefH/ProxyInterfaceGenerator</PackageProjectUrl>
1819
<RepositoryType>git</RepositoryType>
1920
<RepositoryUrl>https://github.com/StefH/ProxyInterfaceGenerator</RepositoryUrl>
20-
21-
<TargetFramework>netstandard2.0</TargetFramework>
22-
<ProjectGuid>{12344228-91F4-4502-9595-39584E5ABB34}</ProjectGuid>
21+
<PackageReadmeFile>PackageReadme.md</PackageReadmeFile>
2322

2423
<IncludeBuildOutput>false</IncludeBuildOutput>
2524
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
@@ -30,6 +29,10 @@
3029
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
3130
</PropertyGroup>
3231

32+
<ItemGroup>
33+
<None Include="../../PackageReadme.md" Pack="true" PackagePath=""/>
34+
</ItemGroup>
35+
3336
<ItemGroup>
3437
<PackageReference Include="AutoMapper" Version="10.1.1" />
3538
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.2">

0 commit comments

Comments
 (0)