Skip to content

Commit

Permalink
准备拆分独立仓库
Browse files Browse the repository at this point in the history
  • Loading branch information
lindexi committed Feb 2, 2024
1 parent a46f667 commit 455e55b
Show file tree
Hide file tree
Showing 103 changed files with 14 additions and 3,503 deletions.
1 change: 0 additions & 1 deletion .github/workflows/nuget publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ jobs:
uses: actions/setup-dotnet@v1
with:
dotnet-version: '8.0.x'
include-prerelease: true

- name: Install dotnet tool
run: dotnet tool install -g dotnetCampus.TagToVersion
Expand Down
6 changes: 3 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
<DevelopmentDependency>true</DevelopmentDependency>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Copyright>Copyright (c) 2018-2023 dotnet-campus</Copyright>
<PackageProjectUrl>https://github.com/dotnet-campus/SourceFusion</PackageProjectUrl>
<RepositoryUrl>https://github.com/dotnet-campus/SourceFusion.git</RepositoryUrl>
<Copyright>Copyright (c) 2018-2024 dotnet-campus</Copyright>
<PackageProjectUrl>https://github.com/dotnet-campus/Telescope</PackageProjectUrl>
<RepositoryUrl>https://github.com/dotnet-campus/Telescope</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>source;dotnet;nuget;msbuild;compile</PackageTags>
</PropertyGroup>
Expand Down
79 changes: 9 additions & 70 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,79 +1,18 @@
# SourceFusion
# Telescope

SourceFusion 是一套预编译框架。
Telescope 是一套预编译框架。

当项目安装 SourceFusion 了之后,项目中即可开始书写预编译代码。通过执行这些预编译代码,项目可以在编译期间执行一些平时需要在运行时执行的代码。这种方式能够将耗时的运行时代码迁移到编译期执行,大幅度提升运行时性能。
当项目安装 Telescope 了之后,项目中即可开始书写预编译代码。通过执行这些预编译代码,项目可以在编译期间执行一些平时需要在运行时执行的代码。这种方式能够将耗时的运行时代码迁移到编译期执行,大幅度提升运行时性能。

|Build|NuGet|
|--|--|
|![](https://github.com/dotnet-campus/SourceFusion/workflows/.NET%20Core/badge.svg)|[![](https://img.shields.io/nuget/v/dotnetCampus.SourceFusion.svg)](https://www.nuget.org/packages/dotnetCampus.SourceFusion)|

## 入门

### 安装 NuGet 包

在 NuGet 源上搜索 `SourceFusion` 寻找已发布的 NuGet 包。由于目前尚未发布正式版,所以你需要指定搜索“预编译版本”才能搜索到此包。

在需要编写预编译代码的项目中安装此 NuGet 包即可。

### 编写预编译代码

你有两种编写预编译代码的方法:
![](https://github.com/dotnet-campus/Telescope/workflows/.NET%20Core/badge.svg)

1. 纯文本代码转换;
1. 模板转换。

以下代码为纯文本预编译代码的 Hello World 实现。HelloWorldTransformer.cs 中的 `Transform` 方法将在编译期间执行,用于将 HelloWorld.cs 文件中的输出改为 `Hello World!`

```csharp
[CompileTimeCode("HelloWorld.cs")]
public class HelloWorldTransformer : IPlainCodeTransformer
{
public string Transform(string originalText, TransformingContext context)
{
return originalText.Replace("Hello", "Hello World!");
}
}
```

```csharp
using System;

public class HelloWorld
{
public void SayHello()
{
Console.WriteLine("Hello");
}
}
```

以下代码为模板转换的 Hello World 实现:
|Package|NuGet|
|--|--|
|Telescope|[![](https://img.shields.io/nuget/v/dotnetCampus.Telescope.svg)](https://www.nuget.org/packages/dotnetCampus.Telescope)|
|Telescope.SourceGeneratorAnalyzers|[![](https://img.shields.io/nuget/v/dotnetCampus.Telescope.SourceGeneratorAnalyzers.svg)](https://www.nuget.org/packages/dotnetCampus.Telescope.SourceGeneratorAnalyzers)|

```csharp
using System;

namespace SourceFusion.Tests
{
[CompileTimeTemplate]
public class HelloWorld
{
public void SayHello()
{
var outputs = Placeholder.Array<string>(context =>
{
// 这里使用两个引号来转义一个引号,最终我们得到了一个包含三个单词部分的数组。
return @"""Hello "", ""World"", ""!""";
});
foreach (var output in outputs)
{
Console.Write(output);
}
}
}
}
```

## 为此项目开发

非常期望你能加入到 SourceFusion 的开发中来,请阅读 [如何为 SourceFusion 贡献代码](/docs/how-to-contribute.md) 了解开发相关的约定和技术要求。
非常期望你能加入到 Telescope 的开发中来,请阅读 [如何为 Telescope 贡献代码](/docs/how-to-contribute.md) 了解开发相关的约定和技术要求。
21 changes: 0 additions & 21 deletions SourceFusion.sln → Telescope.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.6.33723.286
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SourceFusion.Tool", "src\SourceFusion.Tool\SourceFusion.Tool.csproj", "{EFDCE47F-3FCE-4428-9F63-340806876FE5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SourceFusion.Core", "src\SourceFusion\SourceFusion.Core.csproj", "{833511F2-E986-4D5E-8D34-EF53786801F3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SourceFusion.Tests", "tests\SourceFusion.Tests\SourceFusion.Tests.csproj", "{5978AAB0-C4C1-44AF-AB92-27F8ECBF6F69}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{02D03DE5-1A19-4002-92BD-0E3DC61A53C4}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{41B6AF7A-C4D6-42F4-A1D2-A2E4271B2FD3}"
ProjectSection(SolutionItems) = preProject
.gitattributes = .gitattributes
Expand Down Expand Up @@ -64,18 +56,6 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{EFDCE47F-3FCE-4428-9F63-340806876FE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EFDCE47F-3FCE-4428-9F63-340806876FE5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EFDCE47F-3FCE-4428-9F63-340806876FE5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EFDCE47F-3FCE-4428-9F63-340806876FE5}.Release|Any CPU.Build.0 = Release|Any CPU
{833511F2-E986-4D5E-8D34-EF53786801F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{833511F2-E986-4D5E-8D34-EF53786801F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{833511F2-E986-4D5E-8D34-EF53786801F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{833511F2-E986-4D5E-8D34-EF53786801F3}.Release|Any CPU.Build.0 = Release|Any CPU
{5978AAB0-C4C1-44AF-AB92-27F8ECBF6F69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5978AAB0-C4C1-44AF-AB92-27F8ECBF6F69}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5978AAB0-C4C1-44AF-AB92-27F8ECBF6F69}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5978AAB0-C4C1-44AF-AB92-27F8ECBF6F69}.Release|Any CPU.Build.0 = Release|Any CPU
{556913DF-6532-4532-B514-2D1184ADC75B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{556913DF-6532-4532-B514-2D1184ADC75B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{556913DF-6532-4532-B514-2D1184ADC75B}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -121,7 +101,6 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{5978AAB0-C4C1-44AF-AB92-27F8ECBF6F69} = {02D03DE5-1A19-4002-92BD-0E3DC61A53C4}
{50AE25A2-DF1B-4DE9-A7BE-C406F6497376} = {78213588-C3B8-4E86-A19B-73DECD1ABA7B}
{C8BB3F7F-344C-40B4-BF00-005575C8C91A} = {A9879CB9-D164-4A0F-9F7A-D4B86C66BD68}
{350C2DAF-7AD8-4285-9C8F-737D4D078B65} = {A9879CB9-D164-4A0F-9F7A-D4B86C66BD68}
Expand Down
5 changes: 0 additions & 5 deletions build/config.xml

This file was deleted.

2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# SourceFusion
# Telescope

17 changes: 1 addition & 16 deletions docs/how-to-contribute.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,2 @@
# 如何为 SourceFusion 贡献代码
# 如何为 Telescope 贡献代码

SourceFusion 基于 Roslyn 对代码进行编译期分析和执行。

## 核心程序集

核心程序集有两个:

- SourceFusion.Core
- SourceFusion.Tool

SourceFusion.Core 是抽象部分,当作为 NuGet 包安装后,会被目标程序集引用,这样目标程序集可以编写出编译期间运行的的代码。SourceFusion.Tool 是对以上抽象的具体实现部分,当作为 NuGet 包安装后,如果目标程序集执行编译操作,那么此程序集将被执行。也就是说,SourceFusion.Core 的存在是为了让目标程序集能够编写出编译期间执行的代码,而 SourceFusion.Tool 则是执行目标程序集中指定为编译期执行的代码。

这两个程序集有一些开发上的约定。

- SourceFusion.Core 由于会被目标项目通过 PackageReference 的方式引用,所以不要额外引入第三方依赖。
- SourceFusion.Tool 由于其控制台输出被用于特殊用途,所以请不要使用 `Console.WriteLine` 等进行调试。
63 changes: 0 additions & 63 deletions sample/.gitattributes

This file was deleted.

Loading

0 comments on commit 455e55b

Please sign in to comment.