Skip to content

Commit 7daefe0

Browse files
Merge pull request #1196 from icsharpcode/update-to-supported-dotnet
Update to supported dotnet
2 parents 639b7f3 + b18def1 commit 7daefe0

File tree

212 files changed

+3465
-5863
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

212 files changed

+3465
-5863
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ dotnet_diagnostic.RCS1124.severity = none
130130
dotnet_diagnostic.RCS1077.severity = none
131131

132132
# IDE0040: Add accessibility modifiers
133-
dotnet_style_require_accessibility_modifiers = always:warning
133+
dotnet_style_require_accessibility_modifiers = for_non_interface_members:warning
134134

135135
# IDE0048: Add parentheses for clarity
136136
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:none
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# .NET 10 Upgrade Plan
2+
3+
## Execution Steps
4+
5+
Execute steps below sequentially one by one in the order they are listed.
6+
7+
1. Validate that a .NET 10.0 SDK required for this upgrade is installed on the machine and if not, help to get it installed.
8+
2. Ensure that the SDK version specified in global.json files is compatible with the .NET 10.0 upgrade.
9+
3. Upgrade CSharpNetStandardLib/CSharpNetStandardLib.csproj
10+
4. Upgrade ConsoleApp2/CSharpConsoleApp.csproj
11+
5. Upgrade ConsoleApp1/VisualBasicConsoleApp.vbproj
12+
13+
## Settings
14+
15+
### Project upgrade details
16+
17+
#### CSharpNetStandardLib/CSharpNetStandardLib.csproj modifications
18+
19+
Project properties changes:
20+
- Target framework should be changed from `netstandard2.0` to `net10.0`
21+
22+
#### ConsoleApp2/CSharpConsoleApp.csproj modifications
23+
24+
Project file needs to be converted to SDK-style format.
25+
26+
Project properties changes:
27+
- Target framework should be changed from `.NETFramework,Version=v4.8` to `net10.0`
28+
29+
#### ConsoleApp1/VisualBasicConsoleApp.vbproj modifications
30+
31+
Project file needs to be converted to SDK-style format.
32+
33+
Project properties changes:
34+
- Target framework should be changed from `.NETFramework,Version=v4.8` to `net10.0`

.github/workflows/dotnet.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
branches: [ master ]
88

99
env:
10-
BuildVersion: '9.2.7'
10+
BuildVersion: '10.0.0'
1111

1212
jobs:
1313
build:
@@ -30,7 +30,7 @@ jobs:
3030
- name: Setup .NET for main build
3131
uses: actions/setup-dotnet@v4
3232
with:
33-
dotnet-version: 6.0.x
33+
dotnet-version: 10.0.x
3434

3535
- name: Add msbuild to PATH
3636
uses: microsoft/setup-msbuild@v2

.vscode/launch.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
// Use IntelliSense to find out which attributes exist for C# debugging
6+
// Use hover for the description of the existing attributes
7+
// For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md.
8+
"name": ".NET Core Launch (web)",
9+
"type": "coreclr",
10+
"request": "launch",
11+
"preLaunchTask": "build",
12+
// If you have changed target frameworks, make sure to update the program path.
13+
"program": "${workspaceFolder}/Web/bin/Debug/ICSharpCode.CodeConverter.Web.dll",
14+
"args": [],
15+
"cwd": "${workspaceFolder}/Web",
16+
"stopAtEntry": false,
17+
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
18+
"serverReadyAction": {
19+
"action": "openExternally",
20+
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
21+
},
22+
"env": {
23+
"ASPNETCORE_ENVIRONMENT": "Development"
24+
},
25+
"sourceFileMap": {
26+
"/Views": "${workspaceFolder}/Views"
27+
}
28+
},
29+
{
30+
"name": ".NET Core Attach",
31+
"type": "coreclr",
32+
"request": "attach"
33+
}
34+
]
35+
}

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"dotnet.preferCSharpExtension": true,
3+
"dotnet.defaultSolution": "CodeConverter.sln",
4+
"vscode-as-git-mergetool.settingsAssistantOnStartup": false
5+
}

.vscode/tasks.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "build",
6+
"command": "dotnet",
7+
"type": "process",
8+
"args": [
9+
"build",
10+
"${workspaceFolder}/CodeConverter.sln",
11+
"/property:GenerateFullPaths=true",
12+
"/consoleloggerparameters:NoSummary;ForceNoAlign"
13+
],
14+
"problemMatcher": "$msCompile"
15+
},
16+
{
17+
"label": "publish",
18+
"command": "dotnet",
19+
"type": "process",
20+
"args": [
21+
"publish",
22+
"${workspaceFolder}/CodeConverter.sln",
23+
"/property:GenerateFullPaths=true",
24+
"/consoleloggerparameters:NoSummary;ForceNoAlign"
25+
],
26+
"problemMatcher": "$msCompile"
27+
},
28+
{
29+
"label": "watch",
30+
"command": "dotnet",
31+
"type": "process",
32+
"args": [
33+
"watch",
34+
"run",
35+
"--project",
36+
"${workspaceFolder}/CodeConverter.sln"
37+
],
38+
"problemMatcher": "$msCompile"
39+
}
40+
]
41+
}

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
88
### Vsix
99

1010

11+
### VB -> C#
12+
13+
14+
### C# -> VB
15+
16+
17+
## [10.0.0] - 2026-02-06
18+
19+
* Support for net framework dropped. Please use an older version if you are converting projects that still use it.
20+
* dotnet 10 required to run codeconv command line tool
21+
* Improvements to codeconv tool to support converting newer dotnet versions
22+
23+
### Vsix
24+
25+
1126
### VB -> C#
1227

1328
* Xor operator overloads now converted [#1182](htts://github.com/icsharpcode/CodeConverter/issues/1182)
@@ -17,6 +32,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
1732

1833
## [9.2.7] - 2025-02-15
1934

35+
This is the last version that supports net framework.
2036

2137
### Vsix
2238

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net8.0</TargetFramework>
5+
<TargetFramework>net10.0</TargetFramework>
66
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
77
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
88
<IsPackable>true</IsPackable>
@@ -11,7 +11,7 @@
1111
<RootNamespace>ICSharpCode.CodeConverter.CodeConv</RootNamespace>
1212
<ToolCommandName>codeconv</ToolCommandName>
1313
<Description>Bidirectional code converter for VB and C#</Description>
14-
<PackageReadmeFile>PackageReadme.md</PackageReadmeFile>
14+
<PackageReadmeFile>PackageReadme.md</PackageReadmeFile>
1515
<PackageProjectUrl>https://github.com/icsharpcode/CodeConverter/</PackageProjectUrl>
1616
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1717
<PackageIcon>CodeConvNuGetPackageIcon.png</PackageIcon>
@@ -27,34 +27,22 @@
2727

2828
<ItemGroup>
2929
<None Include="CodeConvNuGetPackageIcon.png" Pack="true" PackagePath="" />
30-
<None Include="$(SolutionDir)CommandLine\CodeConv.NetFramework\bin\$(Configuration)\**" LinkBase="..\NetFramework" PackagePath="tools\NetFramework" Pack="true" />
3130
</ItemGroup>
3231

3332
<ItemGroup>
34-
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="7.0.0" />
35-
<PackageReference Include="Microsoft.Build.Locator" Version="1.4.1" />
36-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.1.0" />
37-
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="4.1.0" />
38-
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.1.0" />
33+
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="10.0.2" />
34+
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="17.8.43" />
35+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.14.0" />
36+
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="4.14.0" />
37+
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.14.0" />
3938
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
4039
<PrivateAssets>all</PrivateAssets>
4140
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
4241
</PackageReference>
43-
<PackageReference Include="Microsoft.VisualStudio.Threading" Version="16.10.56" />
44-
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
45-
<PackageReference Include="NuGet.Build.Tasks" Version="6.11.0" />
46-
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
47-
<PackageReference Include="System.Formats.Asn1" Version="8.0.1" />
48-
<PackageReference Include="System.Memory" Version="4.5.5" />
49-
<PackageReference Include="System.Net.Http" Version="4.3.4" />
50-
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
51-
5242
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="4.0.1" />
5343
</ItemGroup>
5444

5545
<ItemGroup>
56-
<ProjectReference Include="..\..\CodeConverter\CodeConverter.csproj" />
46+
<ProjectReference Include="..\CodeConverter\CodeConverter.csproj" />
5747
</ItemGroup>
58-
59-
<Import Project="..\CodeConv.Shared\CodeConv.Shared.projitems" Label="Shared" />
6048
</Project>
File renamed without changes.

CommandLine/CodeConv.Shared/CodeConvProgram.cs renamed to CodeConv/CodeConvProgram.cs

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ public partial class CodeConvProgram
5656
[Option("-f|--force", "Wipe the output directory before conversion", CommandOptionType.NoValue)]
5757
public bool Force { get; }
5858

59-
[Option(CoreOptionDefinition, "Force dot net core build if converting only .NET Core projects and seeing pre-conversion compile errors", CommandOptionType.NoValue)]
60-
public bool CoreOnlyProjects { get; }
61-
6259
[Option("-b|--best-effort", "Overrides warnings about compilation issues with input, and attempts a best effort conversion anyway", CommandOptionType.NoValue)]
6360
public bool BestEffort { get; }
6461

@@ -74,16 +71,6 @@ public partial class CodeConvProgram
7471

7572
private async Task<int> ExecuteAsync()
7673
{
77-
// Ideally we'd be able to use MSBuildLocator.QueryVisualStudioInstances(DiscoveryType.VisualStudioSetup) from .NET core, but it will never be supported: https://github.com/microsoft/MSBuildLocator/issues/61
78-
// Instead, if MSBuild 16.0+ is available, start a .NET framework process and let it run with that
79-
if (_runningInNetCore && !CoreOnlyProjects) {
80-
if (await GetLatestMsBuildExePathAsync() is { } latestMsBuildExePath) {
81-
return await RunNetFrameworkExeAsync(latestMsBuildExePath);
82-
} else {
83-
Console.WriteLine($"Using dot net SDK MSBuild which only works for dot net core projects.");
84-
}
85-
}
86-
8774
try {
8875
Progress<ConversionProgress> progress = new Progress<ConversionProgress>(s => Console.Out.WriteLine(s.ToString()));
8976
await ConvertAsync(progress, CancellationToken.None);
@@ -110,23 +97,6 @@ await Console.Error.WriteLineAsync(Environment.NewLine + ex.Message + Environmen
11097
return 0;
11198
}
11299

113-
private static async Task<int> RunNetFrameworkExeAsync(string latestMsBuildExePath)
114-
{
115-
Console.WriteLine($"Using .NET Framework MSBuild from {latestMsBuildExePath}");
116-
var assemblyDirectoryPath = Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]);
117-
var args = Environment.GetCommandLineArgs().Skip(1).ToArray();
118-
if (string.IsNullOrWhiteSpace(assemblyDirectoryPath)) throw new InvalidOperationException("Could not retrieve executing assembly directory");
119-
var netFrameworkExe = Path.Combine(assemblyDirectoryPath, "..", "..", "NetFramework", "ICSharpCode.CodeConverter.CodeConv.NetFramework.exe");
120-
if (!File.Exists(netFrameworkExe) && Path.GetDirectoryName(assemblyDirectoryPath) is { } assemblyDirectoryParentPath) {
121-
122-
var debugAssemblyDirectoryPath = assemblyDirectoryParentPath.Replace("CommandLine\\CodeConv\\", "CommandLine\\CodeConv.NetFramework\\");
123-
var debugNetFrameworkExe = Path.Combine(debugAssemblyDirectoryPath, "ICSharpCode.CodeConverter.CodeConv.NetFramework.exe");
124-
netFrameworkExe = File.Exists(debugNetFrameworkExe) ? debugNetFrameworkExe : throw new FileNotFoundException($"Cannot find net framework exe at `{netFrameworkExe}`. Using the --core-only flag to get work around this.");
125-
}
126-
var exitCode = await ProcessRunner.ConnectConsoleGetExitCodeAsync(netFrameworkExe, args);
127-
return exitCode;
128-
}
129-
130100
private async Task ConvertAsync(IProgress<ConversionProgress> progress, CancellationToken cancellationToken)
131101
{
132102
string finalSolutionPath = Path.IsPathRooted(SolutionPath)
@@ -150,7 +120,7 @@ private async Task ConvertAsync(IProgress<ConversionProgress> progress, Cancella
150120

151121
var properties = ParsedProperties();
152122
var joinableTaskFactory = new JoinableTaskFactory(new JoinableTaskContext());
153-
var msbuildWorkspaceConverter = new MSBuildWorkspaceConverter(finalSolutionPath, CoreOnlyProjects, joinableTaskFactory, BestEffort, properties);
123+
var msbuildWorkspaceConverter = new MsBuildWorkspaceConverter(joinableTaskFactory, finalSolutionPath, BestEffort, properties);
154124

155125
var converterResultsEnumerable = msbuildWorkspaceConverter.ConvertProjectsWhereAsync(ShouldIncludeProject, TargetLanguage, progress, cancellationToken);
156126
await ConversionResultWriter.WriteConvertedAsync(converterResultsEnumerable, finalSolutionPath, outputDirectory, Force, true, strProgress, cancellationToken);
@@ -179,21 +149,4 @@ private bool ShouldIncludeProject(Project project)
179149
var isIncluded = !Include.Any() || Include.Any(regex => Regex.IsMatch(projectFilePath, regex));
180150
return isIncluded && Exclude.All(regex => !Regex.IsMatch(projectFilePath, regex));
181151
}
182-
183-
private static async Task<string?> GetLatestMsBuildExePathAsync()
184-
{
185-
// The second path here is available on github action agents: https://github.com/microsoft/setup-msbuild#how-does-this-work
186-
var pathsToCheck = new[] {@"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe", @"%ProgramData%\chocolatey\bin"}
187-
.Select(Environment.ExpandEnvironmentVariables).ToArray();
188-
var vsWhereExe = pathsToCheck.FirstOrDefault(File.Exists)
189-
?? throw new FileNotFoundException($"Could not find VSWhere in: {string.Join(", ", pathsToCheck.Select(p => $"`{p}`"))}");
190-
var args = new[] { "-latest", "-prerelease", "-products", "*", "-requires", "Microsoft.Component.MSBuild", "-version", "[16.0,]", "-find", @"MSBuild\**\Bin\MSBuild.exe" };
191-
192-
var (exitCode, stdOut, _) = await new ProcessStartInfo(vsWhereExe) {
193-
Arguments = ArgumentEscaper.EscapeAndConcatenate(args)
194-
}.GetOutputAsync();
195-
196-
if (exitCode == 0 && !string.IsNullOrWhiteSpace(stdOut)) return stdOut;
197-
return null;
198-
}
199152
}

0 commit comments

Comments
 (0)