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

Compilation error for null-conditional operator and comparison (value?.Count > 0) #71

Open
ghost opened this issue Nov 21, 2022 · 4 comments

Comments

@ghost
Copy link

ghost commented Nov 21, 2022

For example this code will fail on build.

    public class TestClass
    {
        private List<(DateTime A, DateTime B)> Values { get; set; }

        public void TestMethod()
        {
            if (this.Values?.Count > 0)
                Console.WriteLine("Hey!");
        }
    }

Most likely it is something introduced with .NET 7 or some sort of regression, as I remember it was successfully built via .NET 6 packages.

@theolivenbaum
Copy link
Collaborator

Hi @HardHub - are you running the latest version of h5 (and have the release version of net7.0 sdk installed)?

@ghost
Copy link
Author

ghost commented Nov 23, 2022

I have used SDK provided by VS 17.4.1 (it is latest on the moment)

dotnet --version
7.0.100

Log:

Rebuild started...
1>------ Rebuild All started: Project: ProjectH5, Configuration: Debug Any CPU ------
Restored D:\Projects\Tests\ProjectH5\ProjectH5\ProjectH5.csproj (in 4 ms).
1>Deleting previous assembly: D:\Projects\Tests\ProjectH5\ProjectH5\bin\Debug\netstandard2.0\ProjectH5.dll
1>'h5' is not recognized as an internal or external command,
1>operable program or batch file.
1>C:\Users\hardhub\.nuget\packages\h5.target\0.0.34005\Sdk\Sdk.targets(461,5): warning MSB3073: The command "h5 check-if-online" exited with code 9009.
1>Cannot find a tool in the manifest file that has a command named 'h5'.
1>C:\Users\hardhub\.nuget\packages\h5.target\0.0.34005\Sdk\Sdk.targets(470,5): warning MSB3073: The command "dotnet tool run h5 check-if-online" exited with code 1.
1>Running _ComputeUserRuntimeAssemblies
1>No output assembly found, will build.
1>Writing project runtime config file D:\Projects\Tests\ProjectH5\ProjectH5\bin\Debug\netstandard2.0\ProjectH5.runtimeconfig.json
1>ProjectH5 ->
1>Installing (or updating) the h5 compiler.
1>You can invoke the tool using the following command: h5
1>Tool 'h5-compiler' (version '0.0.34002') was successfully installed.
1>Deleting previous assembly: D:\Projects\Tests\ProjectH5\ProjectH5\bin\Debug\netstandard2.0\ProjectH5.dll
1>H5 compilation begins now...
1>
1>
1>
1>     5555555555555555555555555555555555555555
1>      5555555555555555555hhhhhhhhhhhhhhhh5555
1>      555     55555555555hh             h5555
1>      555     55555555555hh             h555
1>      555     55555555555hh     hhhhhhhhh555
1>       55     55555555555hh     hhhhhhhhh555
1>       555     5555555555hh     hhhhhhhh5555
1>       555              5hh            h5555
1>       555              5hh            h555
1>        555    5555     5hhhhhhhh      h555
1>        555    5555     5hhhhhhhh      h555
1>        555     555     5hhhhhhhh     h5555
1>        555     555     5hh           h555
1>        5555555 555     5hh        hhhh555
1>         5555555555555555hhhhhhhhhhhhhh555
1>         5555555555555555hhhhhhh5555555555
1>               55555555555555555555
1>                 5555555555555555
1>
1>
1>[info] [14:06:28] Executing h5 compiler with arguments: '--project D:\Projects\Tests\ProjectH5\ProjectH5\ProjectH5.csproj --configuration Debug --assembly-version 1.0.0.0'
1>[info] [14:06:29] Compilation server not online, will start it in the background
1>
1>
1>[info] [14:06:33] Found compilation server, sending compilation request
1>
1>
1>[info] [14:06:33]  Setting working directory to 'D:\Projects\Tests\ProjectH5\ProjectH5'
1>[info] [14:06:33]  [B] H5 Compilation
1>[info] [14:06:33]  H5 config file is not found. Returning default config
1>[info] [14:06:34]  Ready to build D:\Projects\Tests\ProjectH5\ProjectH5\ProjectH5.csproj
1>[info] [14:06:34]  [B] Translating assembly
1>[info] [14:06:34]  Building assembly on path D:\Projects\Tests\ProjectH5\ProjectH5\bin\Debug\netstandard2.0\ProjectH5.dll
1>[info] [14:06:34]  [B] Building assembly 'ProjectH5' for location 'D:\Projects\Tests\ProjectH5\ProjectH5\ProjectH5.csproj'
1>[info] [14:06:34]  NuGet: Importing package Tesserae version 0.0.14660
1>[info] [14:06:34]  NuGet: Importing package h5.Newtonsoft.Json version 0.0.13835
1>[info] [14:06:34]  NuGet: Importing package h5.core version 0.0.13833
1>[info] [14:06:34]  NuGet: Importing package h5 version 0.0.13619
1>[info] [14:06:34]  NuGet: Copying lib file 'C:\Users\hardhub\.nuget\packages\Tesserae\0.0.14660\lib\netstandard2.0\tss.dll' to 'D:\Projects\Tests\ProjectH5\ProjectH5\bin\Debug\netstandard2.0\tss.dll'
1>[info] [14:06:34]  NuGet: Copying lib file 'C:\Users\hardhub\.nuget\packages\h5.Newtonsoft.Json\0.0.13835\lib\netstandard2.0\H5.Newtonsoft.Json.dll' to 'D:\Projects\Tests\ProjectH5\ProjectH5\bin\Debug\netstandard2.0\H5.Newtonsoft.Json.dll'
1>[info] [14:06:34]  NuGet: Copying lib file 'C:\Users\hardhub\.nuget\packages\h5.core\0.0.13833\lib\netstandard2.0\H5.Core.dll' to 'D:\Projects\Tests\ProjectH5\ProjectH5\bin\Debug\netstandard2.0\H5.Core.dll'
1>[info] [14:06:34]  NuGet: Copying lib file 'C:\Users\hardhub\.nuget\packages\h5\0.0.13619\lib\netstandard2.0\H5.dll' to 'D:\Projects\Tests\ProjectH5\ProjectH5\bin\Debug\netstandard2.0\H5.dll'
1>[info] [14:06:34]  Loading references from assembly C:\Users\hardhub\.nuget\packages\Tesserae\0.0.14660\lib\netstandard2.0\tss.dll
1>[info] [14:06:34]  Loading references from assembly C:\Users\hardhub\.nuget\packages\h5.Newtonsoft.Json\0.0.13835\lib\netstandard2.0\H5.Newtonsoft.Json.dll
1>[info] [14:06:34]  Loading references from assembly C:\Users\hardhub\.nuget\packages\h5.core\0.0.13833\lib\netstandard2.0\H5.Core.dll
1>[info] [14:06:34]  Loading references from assembly C:\Users\hardhub\.nuget\packages\h5\0.0.13619\lib\netstandard2.0\H5.dll
1>[info] [14:06:34]  [B] Compiling D:\Projects\Tests\ProjectH5\ProjectH5\bin\Debug\netstandard2.0\ProjectH5.dll with Roslyn
1>[info] [14:06:35]  [E] Compiling D:\Projects\Tests\ProjectH5\ProjectH5\bin\Debug\netstandard2.0\ProjectH5.dll with Roslyn in 1.0100 seconds
1>[info] [14:06:35]  [E] Building assembly 'ProjectH5' for location 'D:\Projects\Tests\ProjectH5\ProjectH5\ProjectH5.csproj' in 1.2700 seconds
1>[info] [14:06:35]  [B] Inspecting references
1>[info] [14:06:35]  [E] Inspecting references in 0.0700 seconds
1>[info] [14:06:35]  Running compiler version 0.0.34002:
1>[info] [14:06:35]  [B] Rewritting code
1>[info] [14:06:36]  [E] Rewritting code in 0.3351 seconds at 6 oper/s, total of 2 operations
1>[info] [14:06:36]  [B] Building syntax tree
1>[info] [14:06:36]  [E] Building syntax tree in 0.1651 seconds
1>[info] [14:06:36]  [E] Translating assembly in 1.8600 seconds
1>[info] [14:06:36]  [E] H5 Compilation in 2.6000 seconds
1>[info] [14:06:36]
1>
1>     __ _  _  _  _
1>    |_ |_)|_)/ \|_)
1>    |__| \| \\_/| \
1>
1>
1>[fail] [14:06:36]
1>H5 : error H5003: Compilation failed (Error parsing code.
1>D:\Projects\Tests\ProjectH5\ProjectH5\TestClass.cs:16,110: Unexpected symbol `A')
1>[fail] [14:06:36]
1>Stack Trace:    at H5.Translator.Translator.BuildSyntaxTree(CancellationToken cancellationToken) in D:\a\1\s\H5\Compiler\Translator\Translator\Translator.InspectAssembly.cs:line 466
1>   at H5.Translator.Translator.Translate(CancellationToken cancellationToken) in D:\a\1\s\H5\Compiler\Translator\Translator\Translator.cs:line 178
1>   at H5.Translator.TranslatorProcessor.Process() in D:\a\1\s\H5\Compiler\Translator\Translator\TranslatorProcessor.cs:line 59
1>   at H5.Compiler.CompilationProcessor.Compile(CompilationRequest compilationRequest, UID128 compilationUID, CancellationToken cancellationToken) in D:\a\1\s\H5\Compiler\Compiler\CompilationProcessor.cs:line 101
1>C:\Users\hardhub\.nuget\packages\h5.target\0.0.34005\Sdk\Sdk.targets(500,5): error MSB3073: The command "h5 --project "D:\Projects\Tests\ProjectH5\ProjectH5\ProjectH5.csproj" --configuration "Debug" --assembly-version "1.0.0.0"" exited with code 1.
1>Done building project "ProjectH5.csproj" -- FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
========== Elapsed 00:49.773 ==========

Build time 00:49:790
Build ended at 23/11/2022 14:06:41

Project file:

<Project Sdk="h5.Target/0.0.34005">
    <PropertyGroup>
        <TargetFramework>netstandard2.0</TargetFramework>
        <LangVersion>7.2</LangVersion>
    </PropertyGroup>

    <ItemGroup>
        <PackageReference Include="h5" Version="0.0.13619" />
        <PackageReference Include="h5.core" Version="0.0.13833" />
        <PackageReference Include="h5.Newtonsoft.Json" Version="0.0.13835" />
        <PackageReference Include="Tesserae" Version="0.0.14660" />
    </ItemGroup>
</Project>

Though in general it is not very good idea to switch to .NET 7 so extremely fast. For example JetBrains Rider still does not support .NET 7. So I even cannot test if it supports H5 well.

@ghost
Copy link
Author

ghost commented Nov 23, 2022

Nothing is changed if project file updated to netstandard 2.1 and fresh version of packages:

<Project Sdk="h5.Target/0.0.34005">
    <PropertyGroup>
        <TargetFramework>netstandard2.1</TargetFramework>
        <LangVersion>7.2</LangVersion>
    </PropertyGroup>

    <ItemGroup>
        <PackageReference Include="h5" Version="0.0.32875" />
        <PackageReference Include="h5.core" Version="0.0.31340" />
        <PackageReference Include="h5.Newtonsoft.Json" Version="0.0.23385" />
        <PackageReference Include="Tesserae" Version="2022.11.34114" />
    </ItemGroup>
</Project>

@theolivenbaum
Copy link
Collaborator

That looks correct - I'll need to investigate more here.

For net70, it shouldn't be an issue with Rider as this is just the dependency from the compiler process to run, not with H5 projects (which are still restricted to netstandard).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant