chore(project): 禁用隐式using并添加全局using文件

- 在所有项目中禁用 ImplicitUsings 配置
- 为所有项目添加 GlobalUsings.cs 文件统一管理常用命名空间
- 统一添加 System、System.Collections.Generic、System.Linq、System.Threading 和 System.Threading.Tasks 的全局引用
- 更新项目文件中的 PackageReference 格式规范化
- 移除各个源文件顶部的重复 using 语句
- 添加标准版权头注释到全局引用文件
This commit is contained in:
GeWuYou 2026-01-27 12:44:51 +08:00
parent 87e11449f1
commit bb95f738a8
26 changed files with 242 additions and 35 deletions

View File

@ -0,0 +1,18 @@
// Copyright (c) 2025 GeWuYou
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
global using System;
global using System.Collections.Generic;
global using System.Linq;
global using System.Threading;
global using System.Threading.Tasks;

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<TargetFrameworks>net10.0;net8.0</TargetFrameworks> <TargetFrameworks>net10.0;net8.0</TargetFrameworks>
</PropertyGroup> </PropertyGroup>

View File

@ -0,0 +1,18 @@
// Copyright (c) 2025 GeWuYou
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
global using System;
global using System.Collections.Generic;
global using System.Linq;
global using System.Threading;
global using System.Threading.Tasks;

View File

@ -1,6 +1,5 @@
using GFramework.Core.Abstractions.enums; using GFramework.Core.Abstractions.enums;
using GFramework.Core.architecture; using GFramework.Core.architecture;
using GFramework.Core.events;
namespace GFramework.Core.Tests.architecture; namespace GFramework.Core.Tests.architecture;

View File

@ -188,6 +188,7 @@ public class YieldInstructionTests
/// <summary> /// <summary>
/// 验证WaitUntil指令应该在条件满足时完成 /// 验证WaitUntil指令应该在条件满足时完成
/// </summary> /// </summary>
[Test]
public void WaitUntil_Should_Be_Done_When_Condition_Is_True() public void WaitUntil_Should_Be_Done_When_Condition_Is_True()
{ {
var counter = 0; var counter = 0;

View File

@ -1,3 +1,4 @@
using System.IO;
using GFramework.Core.Abstractions.logging; using GFramework.Core.Abstractions.logging;
using GFramework.Core.logging; using GFramework.Core.logging;
using NUnit.Framework; using NUnit.Framework;

View File

@ -1,3 +1,4 @@
using System.IO;
using GFramework.Core.Abstractions.logging; using GFramework.Core.Abstractions.logging;
using GFramework.Core.logging; using GFramework.Core.logging;
using NUnit.Framework; using NUnit.Framework;
@ -45,7 +46,7 @@ public class LoggerFactoryTests
public void ConsoleLoggerFactory_GetLogger_WithDefaultMinLevel_ShouldUseInfo() public void ConsoleLoggerFactory_GetLogger_WithDefaultMinLevel_ShouldUseInfo()
{ {
var factory = new ConsoleLoggerFactory(); var factory = new ConsoleLoggerFactory();
var logger = (ConsoleLogger)factory.GetLogger("TestLogger"); _ = (ConsoleLogger)factory.GetLogger("TestLogger");
var stringWriter = new StringWriter(); var stringWriter = new StringWriter();
var testLogger = new ConsoleLogger("TestLogger", LogLevel.Info, stringWriter, false); var testLogger = new ConsoleLogger("TestLogger", LogLevel.Info, stringWriter, false);
@ -66,7 +67,7 @@ public class LoggerFactoryTests
public void ConsoleLoggerFactoryProvider_CreateLogger_ShouldReturnLoggerWithProviderMinLevel() public void ConsoleLoggerFactoryProvider_CreateLogger_ShouldReturnLoggerWithProviderMinLevel()
{ {
var provider = new ConsoleLoggerFactoryProvider { MinLevel = LogLevel.Debug }; var provider = new ConsoleLoggerFactoryProvider { MinLevel = LogLevel.Debug };
var logger = (ConsoleLogger)provider.CreateLogger("TestLogger"); _ = (ConsoleLogger)provider.CreateLogger("TestLogger");
var stringWriter = new StringWriter(); var stringWriter = new StringWriter();
var testLogger = new ConsoleLogger("TestLogger", LogLevel.Debug, stringWriter, false); var testLogger = new ConsoleLogger("TestLogger", LogLevel.Debug, stringWriter, false);
@ -177,7 +178,7 @@ public class LoggerFactoryTests
LoggerFactoryResolver.Provider = provider; LoggerFactoryResolver.Provider = provider;
var logger = (ConsoleLogger)provider.CreateLogger("TestLogger"); _ = (ConsoleLogger)provider.CreateLogger("TestLogger");
var stringWriter = new StringWriter(); var stringWriter = new StringWriter();
var testLogger = new ConsoleLogger("TestLogger", LogLevel.Warning, stringWriter, false); var testLogger = new ConsoleLogger("TestLogger", LogLevel.Warning, stringWriter, false);
@ -204,7 +205,7 @@ public class LoggerFactoryTests
LoggerFactoryResolver.MinLevel = LogLevel.Error; LoggerFactoryResolver.MinLevel = LogLevel.Error;
var provider = LoggerFactoryResolver.Provider; var provider = LoggerFactoryResolver.Provider;
var logger = (ConsoleLogger)provider.CreateLogger("TestLogger"); _ = (ConsoleLogger)provider.CreateLogger("TestLogger");
var stringWriter = new StringWriter(); var stringWriter = new StringWriter();
var testLogger = new ConsoleLogger("TestLogger", LogLevel.Error, stringWriter, false); var testLogger = new ConsoleLogger("TestLogger", LogLevel.Error, stringWriter, false);
@ -241,7 +242,7 @@ public class LoggerFactoryTests
public void ConsoleLoggerFactoryProvider_MinLevel_DoesNotAffectCreatedLogger() public void ConsoleLoggerFactoryProvider_MinLevel_DoesNotAffectCreatedLogger()
{ {
var provider = new ConsoleLoggerFactoryProvider { MinLevel = LogLevel.Error }; var provider = new ConsoleLoggerFactoryProvider { MinLevel = LogLevel.Error };
var logger = provider.CreateLogger("TestLogger"); provider.CreateLogger("TestLogger");
var stringWriter = new StringWriter(); var stringWriter = new StringWriter();
var testLogger = new ConsoleLogger("TestLogger", LogLevel.Error, stringWriter, false); var testLogger = new ConsoleLogger("TestLogger", LogLevel.Error, stringWriter, false);

View File

@ -14,4 +14,5 @@
global using System; global using System;
global using System.Collections.Generic; global using System.Collections.Generic;
global using System.Linq; global using System.Linq;
global using System.Threading;
global using System.Threading.Tasks; global using System.Threading.Tasks;

View File

@ -0,0 +1,18 @@
// Copyright (c) 2025 GeWuYou
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
global using System;
global using System.Collections.Generic;
global using System.Linq;
global using System.Threading;
global using System.Threading.Tasks;

View File

@ -3,7 +3,7 @@
<PropertyGroup> <PropertyGroup>
<PackageId>GeWuYou.$(AssemblyName)</PackageId> <PackageId>GeWuYou.$(AssemblyName)</PackageId>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks> <TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -0,0 +1,18 @@
// Copyright (c) 2025 GeWuYou
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
global using System;
global using System.Collections.Generic;
global using System.Linq;
global using System.Threading;
global using System.Threading.Tasks;

View File

@ -1,4 +1,5 @@
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.IO;
using System.Text; using System.Text;
using GFramework.Game.Abstractions.serializer; using GFramework.Game.Abstractions.serializer;
using GFramework.Game.Abstractions.storage; using GFramework.Game.Abstractions.storage;

View File

@ -0,0 +1,18 @@
// Copyright (c) 2025 GeWuYou
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
global using System;
global using System.Collections.Generic;
global using System.Linq;
global using System.Threading;
global using System.Threading.Tasks;

View File

@ -0,0 +1,18 @@
// Copyright (c) 2025 GeWuYou
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
global using System;
global using System.Collections.Generic;
global using System.Linq;
global using System.Threading;
global using System.Threading.Tasks;

View File

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<PackageId>GeWuYou.$(AssemblyName)</PackageId> <PackageId>GeWuYou.$(AssemblyName)</PackageId>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks> <TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
</PropertyGroup> </PropertyGroup>

View File

@ -0,0 +1,18 @@
// Copyright (c) 2025 GeWuYou
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
global using System;
global using System.Collections.Generic;
global using System.Linq;
global using System.Threading;
global using System.Threading.Tasks;

View File

@ -1,4 +1,5 @@
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.IO;
using System.Text; using System.Text;
using GFramework.Core.Abstractions.storage; using GFramework.Core.Abstractions.storage;
using GFramework.Game.Abstractions.serializer; using GFramework.Game.Abstractions.serializer;

View File

@ -0,0 +1,18 @@
// Copyright (c) 2025 GeWuYou
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
global using System;
global using System.Collections.Generic;
global using System.Linq;
global using System.Threading;
global using System.Threading.Tasks;

View File

@ -0,0 +1,18 @@
// Copyright (c) 2025 GeWuYou
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
global using System;
global using System.Collections.Generic;
global using System.Linq;
global using System.Threading;
global using System.Threading.Tasks;

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<TargetFrameworks>net10.0;net8.0</TargetFrameworks> <TargetFrameworks>net10.0;net8.0</TargetFrameworks>
</PropertyGroup> </PropertyGroup>

View File

@ -0,0 +1,18 @@
// Copyright (c) 2025 GeWuYou
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
global using System;
global using System.Collections.Generic;
global using System.Linq;
global using System.Threading;
global using System.Threading.Tasks;

View File

@ -1,4 +1,5 @@
using Microsoft.CodeAnalysis.CSharp.Testing; using System.IO;
using Microsoft.CodeAnalysis.CSharp.Testing;
using Microsoft.CodeAnalysis.Testing; using Microsoft.CodeAnalysis.Testing;
using NUnit.Framework; using NUnit.Framework;

View File

@ -1,3 +1,4 @@
using System.IO;
using GFramework.SourceGenerators.enums; using GFramework.SourceGenerators.enums;
using GFramework.SourceGenerators.Tests.core; using GFramework.SourceGenerators.Tests.core;
using NUnit.Framework; using NUnit.Framework;

View File

@ -1,3 +1,4 @@
using System.IO;
using GFramework.SourceGenerators.logging; using GFramework.SourceGenerators.logging;
using GFramework.SourceGenerators.Tests.core; using GFramework.SourceGenerators.Tests.core;
using NUnit.Framework; using NUnit.Framework;

View File

@ -1,4 +1,5 @@
using GFramework.SourceGenerators.rule; using System.IO;
using GFramework.SourceGenerators.rule;
using GFramework.SourceGenerators.Tests.core; using GFramework.SourceGenerators.Tests.core;
using NUnit.Framework; using NUnit.Framework;

View File

@ -0,0 +1,18 @@
// Copyright (c) 2025 GeWuYou
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
global using System;
global using System.Collections.Generic;
global using System.Linq;
global using System.Threading;
global using System.Threading.Tasks;