SourceExpander 5.0.0-beta1
See the version list below for details.
dotnet add package SourceExpander --version 5.0.0-beta1
NuGet\Install-Package SourceExpander -Version 5.0.0-beta1
<PackageReference Include="SourceExpander" Version="5.0.0-beta1" />
paket add SourceExpander --version 5.0.0-beta1
#r "nuget: SourceExpander, 5.0.0-beta1"
// Install SourceExpander as a Cake Addin #addin nuget:?package=SourceExpander&version=5.0.0-beta1&prerelease // Install SourceExpander as a Cake Tool #tool nuget:?package=SourceExpander&version=5.0.0-beta1&prerelease
SourceExpander
README languages:
Table of Contents
Packages
SourceExpander(library)
Library that expand embedded source codes.
SourceExpander.Console
Console application that expand embedded source codes.
SourceExpander.Generator
Source generator that expand embedded source codes.
SourceExpander.Embedder
Source generator that embed source codes.
Status
Library | NuGet |
---|---|
SourceExpander | |
SourceExpander.Core | |
SourceExpander.Embedder | |
SourceExpander.Generator | |
SourceExpander.Console |
Getting started
This library require .NET 5 SDK or Visual Studio 16.8 or later because this library use Source Generators.
For library user
Use SourceExpander.Console
Install:
dotnet tool install -g SourceExpander.Console
Run:
# minimum run
dotnet-source-expand Sample/SampleProject2/Program.cs
# specified project
dotnet-source-expand Sample/SampleProject/Put.cs -p Sample/SampleProject2/SampleProject2.csproj
Use SourceExpander.Generator
see Sample or https://github.com/kzrnm/ac-library-csharp
Install-Package SourceExpander
Install-Package <A library with embedded source>
using System;
class Program
{
static void Main()
{
SourceExpander.Expander.Expand();
// Your code
}
}
When you run the code, SourceExpander.Expander.Expand()
create new file that combined library code.
using System;
class Program
{
static void Main()
{
SourceExpander.Expander.Expand();
// Your code
}
}
#region Expanded by https://github.com/kzrnm/SourceExpander
namespace SourceExpander { public class Expander { [Conditional("EXPANDER")] public static void Expand(string inputFilePath = null, string outputFilePath = null, bool ignoreAnyError = true) { } public static string ExpandString(string inputFilePath = null, bool ignoreAnyError = true) { return ""; } } }
// library code
#endregion Expanded by https://github.com/kzrnm/SourceExpander
For library developer
It's easy, just install SourceExpander.Embedder
.
Install-Package SourceExpander.Embedder
Avoid embedding some type
Embedding is skipped for type that have SourceExpander.NotEmbeddingSourceAttribute
.
Notes
Because SourceExpander.Embedder
run at compile time, the embedded source code cannot be used in the same project.
Embedded data
SourceExpander.Embedder
embed some data like below.
using System.Reflection;
[assembly: AssemblyMetadata("SourceExpander.EmbedderVersion", "2.5.0.101")]
[assembly: AssemblyMetadata("SourceExpander.EmbeddedLanguageVersion", "2")]
[assembly: AssemblyMetadata("SourceExpander.EmbeddedAllowUnsafe", "true")]
[assembly: AssemblyMetadata("SourceExpander.EmbeddedSourceCode.GZipBase32768", "㘅桠ҠҠԀᏕ䴾阺㹈斪筟楸厮嫉盆炚磈臤梽胍㦬竂帙詪煩㔬樄ᗗ踜鲯诇ᠩ珱䪜䐽闾鱏珣茙灸䏙⨧㤄寨砳⬅ស䮙松Ꝉ㥅䱀餯ꃣ虱嫁榏㪰糰蝃技夛䥘谼礞䐿斄禕蚷屔彺㪪賳鱥䝢鰨覶⬴誼⬼獬鞨胒宝䭴摺眚䅗䃝䚏隻嫻痛簴Ꜿ変⇣㇋聼欈Ꭽ墷霶勎嶐窢銖㤁┠䁺⠛缧䋹凬☂䁸栣僼邐䑹瘜蛭諠賿㨚咈鍂ꄱ禱唨毊崨叼緭䥜榄闺䦖麷䘘㨵ᖶ琜鎎ᰇ髎飭㪬採ꅈ㥞盧䢽䃘煃⬘喔渻莖案ᯋ硟ꋛ叝谴缄ꍢ⋗溁ᣒ颂浢ꍈꉭ㑆焤鹠杳煄㾳䴡䂱㙽楯裦鷬梙掫取颤⩑㰑㕋ꂤ碎麓㾕昖啘繅餬簚盎鍣䨽籭詽绑襌硲❞擧ꌥ膩辪聫㭒珥㴟囓䓖焜铽痢ꊆꍼᓥ囦纇維Ⲡ㤬垇螇感縋㼎砾褳強襓瀕樥阵瀭蜺兔峃絻藈萢饑㶬櫊綖嶅鏕㻶坶禵䓓Ⴐ咇詤煑⬐毱㱒獅鐥椳䖑ᙋ冄㴼㗭隯顑命貽职葅苫⢸栚䀹䢳噂槝䲰䰮⇷ᔈ⎙䕪絑㝖垿䞉場珟䉛㰭䵶日憭蕼馣㸩涴䓋䃇懚鹯琥镌ⴊ電萞猛流癊⏔恚Ԉң")]
//[assembly: AssemblyMetadata("SourceExpander.EmbeddedSourceCode", "[{\"CodeBody\":\"namespace SampleLibrary { public static class Bit { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int ExtractLowestSetBit(int n) { if (Bmi1.IsSupported) { return (int)Bmi1.ExtractLowestSetBit((uint)n); } return n & -n; } } } \",\"Dependencies\":[],\"FileName\":\"_SampleLibrary>Bit.cs\",\"TypeNames\":[\"SampleLibrary.Bit\"],\"Usings\":[\"using System.Runtime.CompilerServices;\",\"using System.Runtime.Intrinsics.X86;\"]},{\"CodeBody\":\"namespace SampleLibrary { public static class Put { private static readonly Xorshift rnd = new Xorshift(); public static void WriteRandom() { Trace.WriteLine(rnd.Next()); } } } \",\"Dependencies\":[\"_SampleLibrary>Xorshift.cs\"],\"FileName\":\"_SampleLibrary>Put.cs\",\"TypeNames\":[\"SampleLibrary.Put\"],\"Usings\":[\"using System.Diagnostics;\"]},{\"CodeBody\":\"namespace SampleLibrary { public class Xorshift : Random { private uint x = 123456789; private uint y = 362436069; private uint z = 521288629; private uint w; private static readonly Random rnd = new Random(); public Xorshift() : this(rnd.Next()) { } public Xorshift(int seed) { w = (uint)seed; } protected override double Sample() { return InternalSample() * (1.0 \\/ uint.MaxValue); } private uint InternalSample() { uint t = x ^ (x << 11); x = y; y = z; z = w; return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); } } } \",\"Dependencies\":[],\"FileName\":\"_SampleLibrary>Xorshift.cs\",\"TypeNames\":[\"SampleLibrary.Xorshift\"],\"Usings\":[\"using System;\"]}]")]
EmbedderVersion
AssemblyVersion of SourceExpander.Embedder
.
EmbeddedLanguageVersion
C# version of embbeded source code.
EmbeddedAllowUnsafe
if true
, embbeded source code allow unsafe code.
EmbeddedSourceCode
Actually, this metadata does not embedded. for explanation.
json seriarized array of SourceFileInfo
.
public class SourceFileInfo
{
/// <summary>
/// Unique name of file
/// </summary>
public string FileName { get; set; }
/// <summary>
/// Defined types like class, struct, record, enum, delegate
/// </summary>
public IEnumerable<string> TypeNames { get; set; }
/// <summary>
/// Using directives
/// </summary>
public IEnumerable<string> Usings { get; set; }
/// <summary>
/// FileNames that the this depending on
/// </summary>
public IEnumerable<string> Dependencies { get; set; }
/// <summary>
/// Code body that removed using directives
/// </summary>
public string CodeBody { get; set; }
}
EmbeddedSourceCode.GZipBase32768
gzip and base32768 encoded json.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- SourceExpander.Core (>= 5.0.0-beta1)
- SourceExpander.Generator (>= 5.0.0-beta1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
7.0.0 | 161 | 5/10/2024 | |
6.0.0 | 156 | 1/29/2024 | |
5.5.1 | 241 | 10/21/2023 | |
5.5.0 | 126 | 10/21/2023 | |
5.4.0 | 122 | 10/18/2023 | |
5.3.1 | 144 | 9/12/2023 | |
5.3.0 | 116 | 9/12/2023 | |
5.2.0 | 332 | 1/20/2023 | |
5.1.0 | 300 | 12/24/2022 | |
5.0.0 | 535 | 3/16/2022 | |
5.0.0-beta3 | 148 | 3/16/2022 | |
5.0.0-beta2 | 160 | 3/16/2022 | |
5.0.0-beta1 | 153 | 3/15/2022 | |
4.2.0-beta1 | 180 | 3/15/2022 | |
4.2.0-alpha3 | 160 | 3/15/2022 | |
4.2.0-alpha2 | 160 | 3/15/2022 | |
4.1.1 | 451 | 2/26/2022 | |
4.1.0 | 445 | 2/26/2022 | |
4.0.2 | 474 | 1/23/2022 | |
4.0.1 | 466 | 1/22/2022 | |
4.0.0 | 439 | 1/22/2022 | |
4.0.0-beta4 | 176 | 1/21/2022 | |
4.0.0-beta3 | 168 | 1/21/2022 | |
4.0.0-beta2 | 232 | 10/19/2021 | |
4.0.0-beta1 | 210 | 10/19/2021 | |
3.2.1 | 401 | 10/19/2021 | |
3.2.0 | 384 | 6/2/2021 | |
3.1.2 | 358 | 5/3/2021 | |
3.1.1 | 366 | 4/7/2021 | |
3.1.0 | 339 | 4/6/2021 | |
3.0.2 | 387 | 4/3/2021 | |
3.0.0 | 408 | 3/20/2021 | |
3.0.0-beta.2 | 191 | 3/20/2021 | |
3.0.0-beta.1 | 201 | 3/16/2021 | |
2.7.0-beta.2 | 167 | 3/15/2021 | |
2.7.0-beta.1 | 159 | 3/8/2021 | |
2.6.0 | 371 | 2/4/2021 | |
2.5.0 | 446 | 12/18/2020 | |
2.4.1-beta.1 | 202 | 12/16/2020 | |
2.4.0 | 383 | 12/16/2020 | |
2.4.0-beta.3 | 187 | 12/15/2020 | |
2.4.0-beta.2 | 203 | 12/15/2020 | |
2.4.0-beta.1 | 211 | 12/15/2020 | |
2.3.4 | 422 | 12/13/2020 | |
2.3.3 | 412 | 12/13/2020 | |
2.3.2 | 483 | 12/13/2020 | |
2.3.1 | 378 | 12/12/2020 | |
2.3.0-alpha.3 | 225 | 12/10/2020 | |
2.3.0-alpha.2 | 223 | 12/10/2020 | |
2.3.0-alpha.1 | 190 | 12/10/2020 | |
2.2.1 | 454 | 12/6/2020 | |
2.2.0 | 426 | 11/30/2020 | |
2.0.1-beta.1 | 235 | 11/30/2020 | |
2.0.0 | 458 | 11/29/2020 | |
2.0.0-beta.7 | 310 | 11/29/2020 | |
1.1.0-beta.9 | 609 | 11/9/2020 | |
1.1.0-beta.8 | 526 | 10/14/2020 | |
1.1.0-beta.7 | 571 | 10/11/2020 | |
1.1.0-beta.6 | 587 | 10/4/2020 | |
1.1.0-beta.5 | 551 | 10/4/2020 |