Skip to content

Commit

Permalink
Merge pull request #42 from dotnet-campus/t/wzc/UpdateCodeAnalysis
Browse files Browse the repository at this point in the history
升级 Microsoft.CodeAnalysis.CSharp 和添加文件范围命名空间支持
  • Loading branch information
lindexi authored Jan 29, 2024
2 parents 47a8ae3 + e923078 commit a46f667
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 7 deletions.
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
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 @@ -3,13 +3,14 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0;net5.0;netcoreapp3.1;net48</TargetFrameworks>
<RollForward>Major</RollForward>
</PropertyGroup>

<ItemGroup>
<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 +29,5 @@
</ItemGroup>

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

0 comments on commit a46f667

Please sign in to comment.