Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

升级 Microsoft.CodeAnalysis.CSharp 和添加文件范围命名空间支持 #42

Merged
merged 5 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/dotnetcore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
dotnet-version: '8.0.x'
include-prerelease: true
- name: Build with dotnet
run: dotnet build --configuration Release -v n
2 changes: 1 addition & 1 deletion .github/workflows/nuget publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
dotnet-version: '8.0.x'
include-prerelease: true

- name: Install dotnet tool
Expand Down
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<RepositoryUrl>https://github.com/dotnet-campus/SourceFusion.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>source;dotnet;nuget;msbuild;compile</PackageTags>
<RollForward>Major</RollForward>
lindexi marked this conversation as resolved.
Show resolved Hide resolved
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<!-- 现在 VisualStudio 2022 没有带上 .NET Framework 4.5 的负载,为了让大家打开项目就能构建,于是加上这个引用。详细请参阅 https://blog.walterlv.com/post/support-old-netfx-on-vs2022-or-later.html -->
Expand Down
4 changes: 2 additions & 2 deletions src/SourceFusion.Tool/SourceFusion.Tool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

<ItemGroup>
<PackageReference Include="dotnetCampus.CommandLine.Source" Version="3.3.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.8.2" PrivateAssets="all" />
<PackageReference Include="System.Memory" Version="4.5.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" PrivateAssets="all" />
<PackageReference Include="System.Memory" Version="4.5.5" PrivateAssets="All" />
<Reference Include="System.Web"></Reference>
</ItemGroup>

Expand Down
14 changes: 14 additions & 0 deletions src/SourceFusion.Tool/Syntax/CompileTypeVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,20 @@ public override SyntaxNode VisitNamespaceDeclaration(NamespaceDeclarationSyntax
return base.VisitNamespaceDeclaration(node);
}

/// <summary>
/// 获取文件命名空间
/// </summary>
/// <param name="node"></param>
/// <returns></returns>
public override SyntaxNode VisitFileScopedNamespaceDeclaration(FileScopedNamespaceDeclarationSyntax node)
{
var nameSyntax = Visit(node.Name);
// 命名空间
_namespace = nameSyntax.ToFullString().Trim();

return base.VisitFileScopedNamespaceDeclaration(node);
}

/// <summary>
/// 获取类
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.2.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<PackageReference Include="dotnetCampus.CommandLine" Version="3.3.0" PrivateAssets="all" />
<PackageReference Include="dotnetCampus.Configurations" Version="1.2.9" PrivateAssets="all" />
<PackageReference Include="dotnetCampus.MSBuildUtils.Source" Version="1.1.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.8.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" PrivateAssets="all" />
<PackageReference Include="Walterlv.IO.PackageManagement" Version="5.9.0" PrivateAssets="all" />
</ItemGroup>

Expand All @@ -28,5 +28,5 @@
</ItemGroup>

<!-- 这是为了兼容最新版本的预览版的.NET 6构建 -->
<Target Name="GetTargetPath"/>
<Target Name="GetTargetPath" />
</Project>
Loading