Skip to content

Commit 064842b

Browse files
committed
Finished InterfaceTargets
1 parent 94be059 commit 064842b

File tree

59 files changed

+1067
-494
lines changed

Some content is hidden

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

59 files changed

+1067
-494
lines changed

Durian.sln

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{A6400D35-7
6868
docs\Core\DUR0004.md = docs\Core\DUR0004.md
6969
docs\Core\DUR0005.md = docs\Core\DUR0005.md
7070
docs\Core\DUR0007.md = docs\Core\DUR0007.md
71+
docs\Core\DUR0008.md = docs\Core\DUR0008.md
7172
EndProjectSection
7273
EndProject
7374
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DefaultParam", "DefaultParam", "{ED212D80-C490-4BDB-801C-E487EB7E390D}"
@@ -127,6 +128,21 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{D98D
127128
EndProject
128129
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Durian.Samples.DefaultParam", "samples\Durian.Samples.DefaultParam\Durian.Samples.DefaultParam.csproj", "{3B778CDC-7A0E-4D5B-A76E-704E0F854EE9}"
129130
EndProject
131+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Durian.Samples.InterfaceTargets", "samples\Durian.Samples.InterfaceTargets\Durian.Samples.InterfaceTargets.csproj", "{8CACC9A2-DD96-4670-9848-7CC9CE544C86}"
132+
EndProject
133+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Durian.Samples.GenericSpecialization", "samples\Durian.Samples.GenericSpecialization\Durian.Samples.GenericSpecialization.csproj", "{7ABF4D09-45BE-4F7D-BFD6-F8C97E30F1BF}"
134+
EndProject
135+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Durian.Samples.FriendClass", "samples\Durian.Samples.FriendClass\Durian.Samples.FriendClass.csproj", "{2B7CA60B-F172-4DEB-946E-992140A817EC}"
136+
EndProject
137+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "InterfaceTargets", "InterfaceTargets", "{5F891978-E8BA-423F-9125-F02EB33494C4}"
138+
ProjectSection(SolutionItems) = preProject
139+
docs\InterfaceTargets\DUR0401.md = docs\InterfaceTargets\DUR0401.md
140+
docs\InterfaceTargets\DUR0402.md = docs\InterfaceTargets\DUR0402.md
141+
docs\InterfaceTargets\DUR0403.md = docs\InterfaceTargets\DUR0403.md
142+
EndProjectSection
143+
EndProject
144+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Durian.InterfaceTargets.Tests", "tests\Durian.InterfaceTargets.Tests\Durian.InterfaceTargets.Tests.csproj", "{2FFC93C9-1D87-4366-AC28-B26D41C56620}"
145+
EndProject
130146
Global
131147
GlobalSection(SolutionConfigurationPlatforms) = preSolution
132148
Debug|Any CPU = Debug|Any CPU
@@ -446,6 +462,78 @@ Global
446462
{3B778CDC-7A0E-4D5B-A76E-704E0F854EE9}.Release|x64.Build.0 = Release|Any CPU
447463
{3B778CDC-7A0E-4D5B-A76E-704E0F854EE9}.Release|x86.ActiveCfg = Release|Any CPU
448464
{3B778CDC-7A0E-4D5B-A76E-704E0F854EE9}.Release|x86.Build.0 = Release|Any CPU
465+
{8CACC9A2-DD96-4670-9848-7CC9CE544C86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
466+
{8CACC9A2-DD96-4670-9848-7CC9CE544C86}.Debug|Any CPU.Build.0 = Debug|Any CPU
467+
{8CACC9A2-DD96-4670-9848-7CC9CE544C86}.Debug|x64.ActiveCfg = Debug|Any CPU
468+
{8CACC9A2-DD96-4670-9848-7CC9CE544C86}.Debug|x64.Build.0 = Debug|Any CPU
469+
{8CACC9A2-DD96-4670-9848-7CC9CE544C86}.Debug|x86.ActiveCfg = Debug|Any CPU
470+
{8CACC9A2-DD96-4670-9848-7CC9CE544C86}.Debug|x86.Build.0 = Debug|Any CPU
471+
{8CACC9A2-DD96-4670-9848-7CC9CE544C86}.Main Package|Any CPU.ActiveCfg = Debug|Any CPU
472+
{8CACC9A2-DD96-4670-9848-7CC9CE544C86}.Main Package|Any CPU.Build.0 = Debug|Any CPU
473+
{8CACC9A2-DD96-4670-9848-7CC9CE544C86}.Main Package|x64.ActiveCfg = Debug|Any CPU
474+
{8CACC9A2-DD96-4670-9848-7CC9CE544C86}.Main Package|x64.Build.0 = Debug|Any CPU
475+
{8CACC9A2-DD96-4670-9848-7CC9CE544C86}.Main Package|x86.ActiveCfg = Debug|Any CPU
476+
{8CACC9A2-DD96-4670-9848-7CC9CE544C86}.Main Package|x86.Build.0 = Debug|Any CPU
477+
{8CACC9A2-DD96-4670-9848-7CC9CE544C86}.Release|Any CPU.ActiveCfg = Release|Any CPU
478+
{8CACC9A2-DD96-4670-9848-7CC9CE544C86}.Release|Any CPU.Build.0 = Release|Any CPU
479+
{8CACC9A2-DD96-4670-9848-7CC9CE544C86}.Release|x64.ActiveCfg = Release|Any CPU
480+
{8CACC9A2-DD96-4670-9848-7CC9CE544C86}.Release|x64.Build.0 = Release|Any CPU
481+
{8CACC9A2-DD96-4670-9848-7CC9CE544C86}.Release|x86.ActiveCfg = Release|Any CPU
482+
{8CACC9A2-DD96-4670-9848-7CC9CE544C86}.Release|x86.Build.0 = Release|Any CPU
483+
{7ABF4D09-45BE-4F7D-BFD6-F8C97E30F1BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
484+
{7ABF4D09-45BE-4F7D-BFD6-F8C97E30F1BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
485+
{7ABF4D09-45BE-4F7D-BFD6-F8C97E30F1BF}.Debug|x64.ActiveCfg = Debug|Any CPU
486+
{7ABF4D09-45BE-4F7D-BFD6-F8C97E30F1BF}.Debug|x64.Build.0 = Debug|Any CPU
487+
{7ABF4D09-45BE-4F7D-BFD6-F8C97E30F1BF}.Debug|x86.ActiveCfg = Debug|Any CPU
488+
{7ABF4D09-45BE-4F7D-BFD6-F8C97E30F1BF}.Debug|x86.Build.0 = Debug|Any CPU
489+
{7ABF4D09-45BE-4F7D-BFD6-F8C97E30F1BF}.Main Package|Any CPU.ActiveCfg = Debug|Any CPU
490+
{7ABF4D09-45BE-4F7D-BFD6-F8C97E30F1BF}.Main Package|Any CPU.Build.0 = Debug|Any CPU
491+
{7ABF4D09-45BE-4F7D-BFD6-F8C97E30F1BF}.Main Package|x64.ActiveCfg = Debug|Any CPU
492+
{7ABF4D09-45BE-4F7D-BFD6-F8C97E30F1BF}.Main Package|x64.Build.0 = Debug|Any CPU
493+
{7ABF4D09-45BE-4F7D-BFD6-F8C97E30F1BF}.Main Package|x86.ActiveCfg = Debug|Any CPU
494+
{7ABF4D09-45BE-4F7D-BFD6-F8C97E30F1BF}.Main Package|x86.Build.0 = Debug|Any CPU
495+
{7ABF4D09-45BE-4F7D-BFD6-F8C97E30F1BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
496+
{7ABF4D09-45BE-4F7D-BFD6-F8C97E30F1BF}.Release|Any CPU.Build.0 = Release|Any CPU
497+
{7ABF4D09-45BE-4F7D-BFD6-F8C97E30F1BF}.Release|x64.ActiveCfg = Release|Any CPU
498+
{7ABF4D09-45BE-4F7D-BFD6-F8C97E30F1BF}.Release|x64.Build.0 = Release|Any CPU
499+
{7ABF4D09-45BE-4F7D-BFD6-F8C97E30F1BF}.Release|x86.ActiveCfg = Release|Any CPU
500+
{7ABF4D09-45BE-4F7D-BFD6-F8C97E30F1BF}.Release|x86.Build.0 = Release|Any CPU
501+
{2B7CA60B-F172-4DEB-946E-992140A817EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
502+
{2B7CA60B-F172-4DEB-946E-992140A817EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
503+
{2B7CA60B-F172-4DEB-946E-992140A817EC}.Debug|x64.ActiveCfg = Debug|Any CPU
504+
{2B7CA60B-F172-4DEB-946E-992140A817EC}.Debug|x64.Build.0 = Debug|Any CPU
505+
{2B7CA60B-F172-4DEB-946E-992140A817EC}.Debug|x86.ActiveCfg = Debug|Any CPU
506+
{2B7CA60B-F172-4DEB-946E-992140A817EC}.Debug|x86.Build.0 = Debug|Any CPU
507+
{2B7CA60B-F172-4DEB-946E-992140A817EC}.Main Package|Any CPU.ActiveCfg = Debug|Any CPU
508+
{2B7CA60B-F172-4DEB-946E-992140A817EC}.Main Package|Any CPU.Build.0 = Debug|Any CPU
509+
{2B7CA60B-F172-4DEB-946E-992140A817EC}.Main Package|x64.ActiveCfg = Debug|Any CPU
510+
{2B7CA60B-F172-4DEB-946E-992140A817EC}.Main Package|x64.Build.0 = Debug|Any CPU
511+
{2B7CA60B-F172-4DEB-946E-992140A817EC}.Main Package|x86.ActiveCfg = Debug|Any CPU
512+
{2B7CA60B-F172-4DEB-946E-992140A817EC}.Main Package|x86.Build.0 = Debug|Any CPU
513+
{2B7CA60B-F172-4DEB-946E-992140A817EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
514+
{2B7CA60B-F172-4DEB-946E-992140A817EC}.Release|Any CPU.Build.0 = Release|Any CPU
515+
{2B7CA60B-F172-4DEB-946E-992140A817EC}.Release|x64.ActiveCfg = Release|Any CPU
516+
{2B7CA60B-F172-4DEB-946E-992140A817EC}.Release|x64.Build.0 = Release|Any CPU
517+
{2B7CA60B-F172-4DEB-946E-992140A817EC}.Release|x86.ActiveCfg = Release|Any CPU
518+
{2B7CA60B-F172-4DEB-946E-992140A817EC}.Release|x86.Build.0 = Release|Any CPU
519+
{2FFC93C9-1D87-4366-AC28-B26D41C56620}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
520+
{2FFC93C9-1D87-4366-AC28-B26D41C56620}.Debug|Any CPU.Build.0 = Debug|Any CPU
521+
{2FFC93C9-1D87-4366-AC28-B26D41C56620}.Debug|x64.ActiveCfg = Debug|Any CPU
522+
{2FFC93C9-1D87-4366-AC28-B26D41C56620}.Debug|x64.Build.0 = Debug|Any CPU
523+
{2FFC93C9-1D87-4366-AC28-B26D41C56620}.Debug|x86.ActiveCfg = Debug|Any CPU
524+
{2FFC93C9-1D87-4366-AC28-B26D41C56620}.Debug|x86.Build.0 = Debug|Any CPU
525+
{2FFC93C9-1D87-4366-AC28-B26D41C56620}.Main Package|Any CPU.ActiveCfg = Debug|Any CPU
526+
{2FFC93C9-1D87-4366-AC28-B26D41C56620}.Main Package|Any CPU.Build.0 = Debug|Any CPU
527+
{2FFC93C9-1D87-4366-AC28-B26D41C56620}.Main Package|x64.ActiveCfg = Debug|Any CPU
528+
{2FFC93C9-1D87-4366-AC28-B26D41C56620}.Main Package|x64.Build.0 = Debug|Any CPU
529+
{2FFC93C9-1D87-4366-AC28-B26D41C56620}.Main Package|x86.ActiveCfg = Debug|Any CPU
530+
{2FFC93C9-1D87-4366-AC28-B26D41C56620}.Main Package|x86.Build.0 = Debug|Any CPU
531+
{2FFC93C9-1D87-4366-AC28-B26D41C56620}.Release|Any CPU.ActiveCfg = Release|Any CPU
532+
{2FFC93C9-1D87-4366-AC28-B26D41C56620}.Release|Any CPU.Build.0 = Release|Any CPU
533+
{2FFC93C9-1D87-4366-AC28-B26D41C56620}.Release|x64.ActiveCfg = Release|Any CPU
534+
{2FFC93C9-1D87-4366-AC28-B26D41C56620}.Release|x64.Build.0 = Release|Any CPU
535+
{2FFC93C9-1D87-4366-AC28-B26D41C56620}.Release|x86.ActiveCfg = Release|Any CPU
536+
{2FFC93C9-1D87-4366-AC28-B26D41C56620}.Release|x86.Build.0 = Release|Any CPU
449537
EndGlobalSection
450538
GlobalSection(SolutionProperties) = preSolution
451539
HideSolutionNode = FALSE
@@ -472,6 +560,11 @@ Global
472560
{1321229E-C3C2-4B4B-AD81-88B76CB4A938} = {180C285B-7C46-4E5B-9DC9-88439B518746}
473561
{508BEDA0-0AE7-455C-A432-37575FEBA0F3} = {2C1EE0FE-BA67-4CD0-88B8-6DCAFC9806F1}
474562
{3B778CDC-7A0E-4D5B-A76E-704E0F854EE9} = {D98DD137-AADE-4474-86EF-9F0874607687}
563+
{8CACC9A2-DD96-4670-9848-7CC9CE544C86} = {D98DD137-AADE-4474-86EF-9F0874607687}
564+
{7ABF4D09-45BE-4F7D-BFD6-F8C97E30F1BF} = {D98DD137-AADE-4474-86EF-9F0874607687}
565+
{2B7CA60B-F172-4DEB-946E-992140A817EC} = {D98DD137-AADE-4474-86EF-9F0874607687}
566+
{5F891978-E8BA-423F-9125-F02EB33494C4} = {BA3DE2E2-7B32-4612-8219-24FBCF850813}
567+
{2FFC93C9-1D87-4366-AC28-B26D41C56620} = {F6EC89D8-4343-42A1-B6D6-B0022D3004A0}
475568
EndGlobalSection
476569
GlobalSection(ExtensibilityGlobals) = postSolution
477570
SolutionGuid = {09524C45-0D6D-4456-B89D-9673853B9FA0}

README.md

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@
2121

2222
**Durian is a collection of Roslyn-based analyzers, source generators and utility libraries that bring many extensions to C#, with heavy emphasis on features that can be found in other existing languages. It's main goal is to make C# easier and more pleasant to use through reducing necessary boilerplate code, while at the same time providing additional layers of flexibility.**
2323

24+
## Current state
25+
26+
Durian is at an early stage of its evolution - many core features are still missing, being either in early development or planning phase. As for now, only one fully-fledged module is complete - *DefaultParam*, with *InterfaceTargets* awaiting in experimental stage for release in the closest future.
27+
2428
## Features
2529

26-
**To see more about a specific feature, click on its name.**
30+
To see more about a specific feature, click on its name.
2731

2832
### [DefaultParam](src/Durian.DefaultParam/README.md)
29-
DefaultParam allows to specify a default type for a generic parameter.
33+
*DefaultParam* allows to specify a default type for a generic parameter.
3034

3135
```csharp
3236
using Durian;
@@ -56,21 +60,37 @@ class Program
5660

5761
```
5862

59-
## Current state
63+
## Experimental
6064

61-
Right now, Durian is only at the first stage of its evolution. As for its initial release on the 2nd of June 2021, two modules - *Core* and *DefaultParam* - are available, with additional two - *StructInherit* and *GenericSpecialization* - in early development. This does not include two already existing packages that are not part of any module - *Durian.AnalysisServices* and *Durian.TestServices*.
65+
### [InterfaceTargets](src/Durian.InterfaceTargets/README.md)
6266

63-
For more information about a specific package or module, go to the *README.md* file in the according project's directory in the *\\src\\* folder.
67+
*InterfaceTargets*, similar to how [System.AttributeUsageAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.attributeusageattribute?view=net-5.0) works, allows to specify what kinds of members an interface can be implemented by.
6468

65-
## What's next?
69+
```csharp
70+
using Durian;
6671

67-
At the moment, two modules are in experimental stage - *StructInherit* and *GenericSpecialization*, with the latter being further in development. Release dates are yet to be determined.
72+
[InterfaceTargets(InterfaceTargets.Class)]
73+
public interface ITest
74+
{
75+
}
6876

69-
## History
77+
// OK
78+
// ITest can be implemented, because ClassTest is a class.
79+
public class ClassTest : ITest
80+
{
81+
}
82+
83+
// Error!
84+
// ITest cannot be implemented, because StructTest is a struct, and ITest is valid only for classes.
85+
public struct StructTest : ITest
86+
{
87+
}
88+
89+
```
7090

71-
Durian started as a personal project of a high school student from Gdañsk, Poland - Piotr Stenke, amateur C# programmer and Unity Engine enthusiast. Though the sole idea for a Roslyn-based platform emerged in late 2020, any actual work didn't take place until February 2021. First months of development were especially challenging, with final exams in school, deadly virus roaming all around the globe and adult life slowly, but steadily, approaching. And all of that without even mentioning the worst part - learning from scratch this awful, unintuitive, badly-documented mess of an API that is Roslyn.
91+
## What's next?
7292

73-
At its initial release on the 2nd of June 2021, Durian was meant to be a major card that would get its author into the IT industry.
93+
With *InterfaceTargets* being close to leaving the experimental stage, two more features are almost ready to take its place - *GenericSpecialization* and *FriendClass*. Both are planned to be moved to experimental stage in late August - early September 2021.
7494

7595
##
7696

docs/Core/DUR0006.md

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

docs/Core/DUR0007.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ The Durian analyzer packages are:
1010
- [Durian.Core.Analyzer](../../src/Durian.Core.Analyzer/README.md)
1111
- [Durian.DefaultParam](../../src/Durian.DefaultParam/README.md)
1212
- [Durian.GenericSpecialization](../../src/Durian.GenericSpecialization/README.md)
13+
- [Durian.FriendClass](../../src/Durian.FriendClass/README.md)
14+
- [Durian.InterfaceTargets](../../src/Durian.InterfaceTargets/README.md)
1315

1416
##
1517

docs/Core/DUR0008.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# DUR0008 - Warning
2+
### Separate analyzer packages detected, reference the main Durian package instead for better performance.
3+
4+
## Remarks:
5+
6+
This diagnostic is reported when a project references more than once Durian analyzer package, but not the main [Durian](https://www.nuget.org/packages/Durian/) package.
7+
8+
Every Durian analyzer package references [Durian.Core](../../src/Durian.Core/README.md) and [Durian.AnalysisServices](../../src/Durian.AnalysisServices/README.md). Since each analyzer package is its own being and has no knowledge of other analyzers, both [Durian.Core](../../src/Durian.Core/README.md) and [Durian.AnalysisServices](../../src/Durian.AnalysisServices/README.md) have to be loaded into memory once per each of those packages. For example, if a project references [Durian.DefaultParam](../../src/Durian.DefaultParam/README.md) and [Durian.InterfaceTargets](../../src/Durian.InterfaceTargets/README.md), [Durian.Core](../../src/Durian.Core/README.md) and [Durian.AnalysisServices](../../src/Durian.AnalysisServices/README.md) will be loaded twice - once for [Durian.DefaultParam](../../src/Durian.DefaultParam/README.md), once for [Durian.InterfaceTargets](../../src/Durian.InterfaceTargets/README.md). In such circumstances, in order to eliminate memory waste, it is recommended to use the main [Durian](https://www.nuget.org/packages/Durian/) package.
9+
##
10+
11+
*\(Written by Piotr Stenke\)*

docs/InterfaceTargets/DUR0401.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# DUR0401 - Error
2+
### Interface is not valid on members of this kind.
3+
4+
## Example 1
5+
6+
### Code with diagnostic:
7+
```csharp
8+
using Durian;
9+
10+
[InterfaceTargets(InterfaceTargets.Interface)]
11+
public interface ITest
12+
{
13+
}
14+
15+
// DUR0401
16+
public class Test : ITest
17+
{
18+
}
19+
20+
```
21+
22+
## Example 2
23+
24+
### Code with diagnostic:
25+
```csharp
26+
using Durian;
27+
28+
[InterfaceTargets(InterfaceTargets.Class | InterfaceTargets.Interface)]
29+
public interface ITest
30+
{
31+
}
32+
33+
// DUR0401
34+
public struct Test : ITest
35+
{
36+
}
37+
38+
```
39+
40+
##
41+
42+
*\(Written by Piotr Stenke\)*

docs/InterfaceTargets/DUR0402.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# DUR0402 - Error
2+
### Interface cannot be a base of another interface.
3+
4+
## Example 1
5+
6+
### Code with diagnostic:
7+
```csharp
8+
using Durian;
9+
10+
[InterfaceTargets(InterfaceTargets.Class)]
11+
public interface ITest
12+
{
13+
}
14+
15+
// DUR0402
16+
public interface Test : ITest
17+
{
18+
}
19+
20+
```
21+
22+
## Example 2
23+
24+
### Code with diagnostic:
25+
```csharp
26+
using Durian;
27+
28+
[InterfaceTargets(InterfaceTargets.Class | InterfaceTargets.Struct)]
29+
public interface ITest
30+
{
31+
}
32+
33+
// DUR0402
34+
public interface Test : ITest
35+
{
36+
}
37+
38+
```
39+
40+
##
41+
42+
*\(Written by Piotr Stenke\)*

docs/InterfaceTargets/DUR0403.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# DUR0403 - Error
2+
### Interface is accessible only through reflection.
3+
4+
## Example
5+
6+
### Code with diagnostic:
7+
```csharp
8+
using Durian;
9+
10+
[InterfaceTargets(InterfaceTargets.ReflectionOnly)]
11+
public interface ITest
12+
{
13+
}
14+
15+
// DUR0403
16+
public class Test : ITest
17+
{
18+
}
19+
20+
```
21+
22+
##
23+
24+
*\(Written by Piotr Stenke\)*

img/icons/Durian.Core-256.png

-25.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)