Initial MVP

This commit is contained in:
Smaug123
2024-10-02 23:25:20 +01:00
parent 2e6d2ded51
commit 0dad74819e
23 changed files with 1491 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
namespace WoofWare.Whippet.Core
(*
These types should take no dependencies and should only change additively; otherwise consumers will break!
*)
/// When decorating a type, indicates that the type contains Whippet generators.
///
/// If you don't want to take a dependency on WoofWare.Whippet.Core, you can define your own attribute with this name,
/// and we'll detect it happily when running the plugin.
type WhippetGeneratorAttribute () =
inherit System.Attribute ()
/// The arguments we'll give you (a plugin) when we call you to generate some code from raw file input.
type RawSourceGenerationArgs =
{
/// Full path to the file, on disk, which you're taking as input.
FilePath : string
/// Contents of the file; you might want to `System.Text.Encoding.UTF8.GetString` this.
FileContents : byte[]
}
/// We provide this interface as a helper to give you compile-time safety, but you don't have to use it.
/// At runtime, we'll find any member with the right name and signature.
/// You must use `RawSourceGenerationArgs`, though!
type IGenerateRawFromRaw =
/// Return `null` to indicate "I don't want to do any updates".
abstract member GenerateRawFromRaw : RawSourceGenerationArgs -> string

View File

@@ -0,0 +1,19 @@
# WoofWare.Whippet.Core
This library defines the types you will need to create a plugin that works with the WoofWare.Whippet source generator,
as well as some types which you may find convenient for this purpose.
To the greatest extent possible, WoofWare.Whippet is structured so that if you wish, you do not need to use this library.
However, there are some types you *must* use.
## Mandatory types
When defining any method which performs source generation, you must use the appropriate input type
(such as `RawSourceGenerationArgs`).
We try *very hard* to ensure we never break backward compatibility, so you should safely be able to use old versions of
WoofWare.Whippet.Core even with new versions of the WoofWare.Whippet generator.
## Optional types
* You must decorate your plugin types with an attribute named `[<WhippetGenerator>]`. We supply one you can use.
* We supply interfaces from which you can inherit, to ensure that you are providing members of the right type signature.

View File

@@ -0,0 +1,11 @@
WoofWare.Whippet.Core.IGenerateRawFromRaw - interface with 1 member(s)
WoofWare.Whippet.Core.IGenerateRawFromRaw.GenerateRawFromRaw [method]: WoofWare.Whippet.Core.RawSourceGenerationArgs -> string
WoofWare.Whippet.Core.RawSourceGenerationArgs inherit obj, implements WoofWare.Whippet.Core.RawSourceGenerationArgs System.IEquatable, System.Collections.IStructuralEquatable, WoofWare.Whippet.Core.RawSourceGenerationArgs System.IComparable, System.IComparable, System.Collections.IStructuralComparable
WoofWare.Whippet.Core.RawSourceGenerationArgs..ctor [constructor]: (string, System.Byte [])
WoofWare.Whippet.Core.RawSourceGenerationArgs.Equals [method]: (WoofWare.Whippet.Core.RawSourceGenerationArgs, System.Collections.IEqualityComparer) -> bool
WoofWare.Whippet.Core.RawSourceGenerationArgs.FileContents [property]: [read-only] System.Byte []
WoofWare.Whippet.Core.RawSourceGenerationArgs.FilePath [property]: [read-only] string
WoofWare.Whippet.Core.RawSourceGenerationArgs.get_FileContents [method]: unit -> System.Byte []
WoofWare.Whippet.Core.RawSourceGenerationArgs.get_FilePath [method]: unit -> string
WoofWare.Whippet.Core.WhippetGeneratorAttribute inherit System.Attribute
WoofWare.Whippet.Core.WhippetGeneratorAttribute..ctor [constructor]: unit

View File

@@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Authors>Patrick Stevens</Authors>
<Copyright>Copyright (c) Patrick Stevens 2024</Copyright>
<Description>Core library types to allow you to use the WoofWare.Whippet source generator.</Description>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/Smaug123/WoofWare.Whippet</RepositoryUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageTags>fsharp;source-generator;source-gen</PackageTags>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarnOn>FS3559</WarnOn>
<PackageId>WoofWare.Whippet.Core</PackageId>
</PropertyGroup>
<ItemGroup>
<Compile Include="Domain.fs" />
<EmbeddedResource Include="SurfaceBaseline.txt" />
<None Include="version.json" />
<None Include="README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Update="FSharp.Core" Version="4.3.4" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,11 @@
{
"version": "0.1",
"publicReleaseRefSpec": [
"^refs/heads/main$"
],
"pathFilters": [
"./",
":/global.json",
":/Directory.Build.props"
]
}