问:
Project Loading Failed. Empty Project and Freshly installed VScode and Unity
I created an empty project and a C# script file .When I tried to open script in vs code project loading failed.

This is my Omnisharp Output.
`

```<code>    Starting OmniSharp server at 12/17/2022, 8:14:59 AM
        Target: f:\BarryAllen14\Unity Projects\My project\My project.sln

    OmniSharp server started.
        Path: c:\Users\SMME\.vscode\extensions\ms-dotnettools.csharp-1.25.2-win32-x64\.omnisharp\1.39.2\OmniSharp.exe
        PID: 8820

    [info]: OmniSharp.Stdio.Host
            Starting OmniSharp on Windows 6.2.9200.0 (x64)
    [info]: OmniSharp.Services.DotNetCliService
            Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
    [info]: OmniSharp.Services.DotNetCliService
            Using the 'dotnet' on the PATH.
    [info]: OmniSharp.Services.DotNetCliService
            DotNetPath set to dotnet
    [info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
            Located 1 MSBuild instance(s)
                1: Visual Studio Build Tools 2022 17.4.33205.214 17.4.1 - "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin"
    [info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
            Registered MSBuild instance: Visual Studio Build Tools 2022 17.4.33205.214 17.4.1 - "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin"
    [info]: OmniSharp.WorkspaceInitializer
            Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
    [info]: OmniSharp.Cake.CakeProjectSystem
            Detecting Cake files in 'f:\BarryAllen14\Unity Projects\My project'.
    [info]: OmniSharp.Cake.CakeProjectSystem
            Did not find any Cake files
    [info]: OmniSharp.MSBuild.ProjectSystem
            Detecting projects in 'f:\BarryAllen14\Unity Projects\My project\My project.sln'.
    [info]: OmniSharp.MSBuild.ProjectManager
            Queue project update for 'f:\BarryAllen14\Unity Projects\My project\Assembly-CSharp.csproj'
    [info]: OmniSharp.Script.ScriptProjectSystem
            Detecting CSX files in 'f:\BarryAllen14\Unity Projects\My project'.
    [info]: OmniSharp.Script.ScriptProjectSystem
            Did not find any CSX files
    [info]: OmniSharp.WorkspaceInitializer
            Configuration finished.
    [info]: OmniSharp.Stdio.Host
            Omnisharp server running using Stdio at location 'f:\BarryAllen14\Unity Projects\My project' on host 16560.
    [info]: OmniSharp.MSBuild.ProjectManager
            Loading project: f:\BarryAllen14\Unity Projects\My project\Assembly-CSharp.csproj
    [info]: OmniSharp.MSBuild.ProjectManager
            Successfully loaded project file 'f:\BarryAllen14\Unity Projects\My project\Assembly-CSharp.csproj'.
    [info]: OmniSharp.MSBuild.ProjectManager
            Adding project 'f:\BarryAllen14\Unity Projects\My project\Assembly-CSharp.csproj'
    [info]: OmniSharp.MSBuild.ProjectManager
            Update project: Assembly-CSharp

</code>```

** This is my Assembly-CSharp.csproj file.**

```<code>    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup>
        <LangVersion>9.0</LangVersion>
      </PropertyGroup>
      <PropertyGroup>
        <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
        <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
        <ProductVersion>10.0.20506</ProductVersion>
        <SchemaVersion>2.0</SchemaVersion>
        <RootNamespace></RootNamespace>
        <ProjectGuid>{e6bdc332-25e1-2831-82c1-25d0441455a3}</ProjectGuid>
        <OutputType>Library</OutputType>
        <AppDesignerFolder>Properties</AppDesignerFolder>
        <AssemblyName>Assembly-CSharp</AssemblyName>
        <TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
        <FileAlignment>512</FileAlignment>
        <BaseDirectory>.</BaseDirectory>
      </PropertyGroup>
      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
        <DebugSymbols>true</DebugSymbols>
        <DebugType>full</DebugType>
        <Optimize>false</Optimize>
        <OutputPath>Temp\bin\Debug\</OutputPath>
        <DefineConstants>DEBUG;TRACE;UNITY_2021_3_16;UNITY_2021_3;UNITY_2021;UNITY_5_3_OR_NEWER;UNITY_5_4_OR_NEWER;UNITY_5_5_OR_NEWER;UNITY_5_6_OR_NEWER;UNITY_2017_1_OR_NEWER;UNITY_2017_2_OR_NEWER;UNITY_2017_3_OR_NEWER;UNITY_2017_4_OR_NEWER;UNITY_2018_1_OR_NEWER;UNITY_2018_2_OR_NEWER;UNITY_2018_3_OR_NEWER;UNITY_2018_4_OR_NEWER;UNITY_2019_1_OR_NEWER;UNITY_2019_2_OR_NEWER;UNITY_2019_3_OR_NEWER;UNITY_2019_4_OR_NEWER;UNITY_2020_1_OR_NEWER;UNITY_2020_2_OR_NEWER;UNITY_2020_3_OR_NEWER;UNITY_2021_1_OR_NEWER;UNITY_2021_2_OR_NEWER;UNITY_2021_3_OR_NEWER;PLATFORM_ARCH_64;UNITY_64;UNITY_INCLUDE_TESTS;ENABLE_AR;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_EVENT_QUEUE;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_TEXTURE_STREAMING;ENABLE_VIRTUALTEXTURING;ENABLE_UNET;ENABLE_LZMA;ENABLE_UNITYEVENTS;ENABLE_VR;ENABLE_WEBCAM;ENABLE_UNITYWEBREQUEST;ENABLE_WWW;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_COLLAB;ENABLE_CLOUD_SERVICES_COLLAB_SOFTLOCKS;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_SERVICES_USE_WEBREQUEST;ENABLE_CLOUD_SERVICES_CRASH_REPORTING;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_LICENSE;ENABLE_EDITOR_HUB_LICENSE;ENABLE_WEBSOCKET_CLIENT;ENABLE_DIRECTOR_AUDIO;ENABLE_DIRECTOR_TEXTURE;ENABLE_MANAGED_JOBS;ENABLE_MANAGED_TRANSFORM_JOBS;ENABLE_MANAGED_ANIMATION_JOBS;ENABLE_MANAGED_AUDIO_JOBS;ENABLE_MANAGED_UNITYTLS;INCLUDE_DYNAMIC_GI;ENABLE_SCRIPTING_GC_WBARRIERS;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;ENABLE_VIDEO;ENABLE_ACCELERATOR_CLIENT_DEBUGGING;PLATFORM_STANDALONE;TEXTCORE_1_0_OR_NEWER;PLATFORM_STANDALONE_WIN;UNITY_STANDALONE_WIN;UNITY_STANDALONE;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_NVIDIA;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_UNITY_GAME_SERVICES_ANALYTICS_SUPPORT;ENABLE_OUT_OF_PROCESS_CRASH_HANDLER;ENABLE_CLUSTER_SYNC;ENABLE_CLUSTERINPUT;PLATFORM_UPDATES_TIME_OUTSIDE_OF_PLAYER_LOOP;GFXDEVICE_WAITFOREVENT_MESSAGEPUMP;ENABLE_WEBSOCKET_HOST;ENABLE_MONO;NET_STANDARD_2_0;NET_STANDARD;NET_STANDARD_2_1;NETSTANDARD;NETSTANDARD2_1;ENABLE_PROFILER;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_WIN;ENABLE_UNITY_COLLECTIONS_CHECKS;ENABLE_BURST_AOT;UNITY_TEAM_LICENSE;UNITY_PRO_LICENSE;ENABLE_CUSTOM_RENDER_TEXTURE;ENABLE_DIRECTOR;ENABLE_LOCALIZATION;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_TILEMAP;ENABLE_TIMELINE;ENABLE_LEGACY_INPUT_MANAGER;TEXTCORE_FONT_ENGINE_1_5_OR_NEWER;CSHARP_7_OR_LATER;CSHARP_7_3_OR_NEWER</DefineConstants>
        <ErrorReport>prompt</ErrorReport>
        <WarningLevel>4</WarningLevel>
        <NoWarn>0169</NoWarn>
        <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
      </PropertyGroup>
      <PropertyGroup>
        <NoConfig>true</NoConfig>
        <NoStdLib>true</NoStdLib>
        <AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
        <ImplicitlyExpandNETStandardFacades>false</ImplicitlyExpandNETStandardFacades>
        <ImplicitlyExpandDesignTimeFacades>false</ImplicitlyExpandDesignTimeFacades>
      </PropertyGroup>
      <ItemGroup>
         <Compile Include="Assets\abc.cs" />
        <Reference Include="UnityEngine">
            <HintPath>C:\Program Files\Unity\Hub\Editor\2021.3.16f1\Editor\Data\Managed\UnityEngine\UnityEngine.dll</HintPath>
        </Reference>
        <Reference Include="UnityEngine.AIModule">
            <HintPath>C:\Program Files\Unity\Hub\Editor\2021.3.16f1\Editor\Data\Managed\UnityEngine\UnityEngine.AIModule.dll</HintPath>
        </Reference>
        <Reference Include="UnityEngine.ARModule">
            <HintPath>C:\Program Files\Unity\Hub\Editor\2021.3.16f1\Editor\Data\Managed\UnityEngine\UnityEngine.ARModule.dll</HintPath>
        </Reference>
        <Reference Include="UnityEngine.AccessibilityModule">
            <HintPath>C:\Program Files\Unity\Hub\Editor\2021.3.16f1\Editor\Data\Managed\UnityEngine\UnityEngine.AccessibilityModule.dll</HintPath>
        </Reference>
        <Reference Include="UnityEngine.AndroidJNIModule">
            <HintPath>C:\Program Files\Unity\Hub\Editor\2021.3.16f1\Editor\Data\Managed\UnityEngine\UnityEngine.AndroidJNIModule.dll</HintPath>
        </Reference>
        <Reference Include="UnityEngine.AnimationModule">
            <HintPath>C:\Program Files\Unity\Hub\Editor\2021.3.16f1\Editor\Data\Managed\UnityEngine\UnityEngine.AnimationModule.dll</HintPath>
        </Reference>
        <Reference Include="UnityEngine.AssetBundleModule">
            <HintPath>C:\Program Files\Unity\Hub\Editor\2021.3.16f1\Editor\Data\Managed\UnityEngine\UnityEngine.AssetBundleModule.dll</HintPath>
        </Reference>
        <Reference Include="UnityEngine.AudioModule">
            <HintPath>C:\Program Files\Unity\Hub\Editor\2021.3.16f1\Editor\Data\Managed\UnityEngine\UnityEngine.AudioModule.dll</HintPath>
        </Reference>
        <Reference Include="UnityEngine.ClothModule">
            <HintPath>C:\Program Files\Unity\Hub\Editor\2021.3.16f1\Editor\Data\Managed\UnityEngine\UnityEngine.ClothModule.dll</HintPath>
        </Reference>
        <Reference Include="UnityEngine.ClusterInputModule">
            <HintPath>C:\Program Files\Unity\Hub\Editor\2021.3.16f1\Editor\Data\Managed\UnityEngine\UnityEngine.ClusterInputModule.dll</HintPath>
        </Reference>
        <Reference Include="UnityEngine.ClusterRendererModule">
            <HintPath>C:\Program Files\Unity\Hub\Editor\2021.3.16f1\Editor\Data\Managed\UnityEngineth>
        </Reference>

        <Reference Include="Unity.VisualScripting.Core">
            <HintPath>F:\BarryAllen14\Unity Projects\My project\Library\ScriptAssemblies\Unity.VisualScripting.Core.dll</HintPath>
        </Reference>
        <Reference Include="Unity.EditorCoroutines.Editor">
            <HintPath>F:\BarryAllen14\Unity Projects\My project\Library\ScriptAssemblies\Unity.EditorCoroutines.Editor.dll</HintPath>
        </Reference>
        <Reference Include="Unity.Services.Core.Analytics">
            <HintPath>F:\BarryAllen14\Unity Projects\My project\Library\ScriptAssemblies\Unity.Services.Core.Analytics.dll</HintPath>
        </Reference>
        <Reference Include="Unity.VisualScripting.Shared.Editor">
            <HintPath>F:\BarryAllen14\Unity Projects\My project\Library\ScriptAssemblies\Unity.VisualScripting.Shared.Editor.dll</HintPath>
        </Reference>
        <Reference Include="Unity.Services.Core.Environments">
            <HintPath>F:\BarryAllen14\Unity Projects\My project\Library\ScriptAssemblies\Unity.Services.Core.Environments.dll</HintPath>
        </Reference>
        <Reference Include="Unity.Timeline.Editor">
            <HintPath>F:\BarryAllen14\Unity Projects\My project\Library\ScriptAssemblies\Unity.Timeline.Editor.dll</HintPath>
        </Reference>
        <Reference Include="Unity.TestTools.CodeCoverage.Editor">
            <HintPath>F:\BarryAllen14\Unity Projects\My project\Library\ScriptAssemblies\Unity.TestTools.CodeCoverage.Editor.dll</HintPath>
        </Reference>
        <Reference Include="Unity.VisualScripting.State">
            <HintPath>F:\BarryAllen14\Unity Projects\My project\Library\ScriptAssemblies\Unity.VisualScripting.State.dll</HintPath>
        </Reference>
      </ItemGroup>
      <ItemGroup>
      </ItemGroup>
      <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
      <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
           Other similar extension points exist, see Microsoft.Common.targets.
      <Target Name="BeforeBuild">
      </Target>
      <Target Name="AfterBuild">
      </Target>
      -->
    </Project>

</code>```

`
when I click Project loading Failed at the bottom of the screen. Assembly-CSharp.csproj status file opens with following text.
.

This happens with every project I create both new one and old one.
Originally I was following pathway from my unity learn, when i treid to use **onTriggerEnter **function vscode didnt autocomplete it, so manually typed it. But i didnt work like it is supposed to. vscode was treating it as user defined build function not as monobehaviour function. I searched for possible reasons on unity forums, stack exchange and reddit but none of the solution worked for me.
So uninstalled Unity, VScode and .net frameworks. And installed everyth from scratch following these two guides.

https://code.visualstudio.com/docs/other/unity
https://code.visualstudio.com/docs/languages/dotnet

Now my freshly installed Unity and VScode is not even loading project properly.

My 2 days has been wasted. plz help me.

I also psoted the same thing in unity forum and according to replies this is problem is more likely due to vscode not unity editor.

Body:
I created an empty project and a C# script file .When I tried to open script in vs code project loading failed.

This is my Omnisharp Output.
`

    Starting OmniSharp server at 12/17/2022, 8:14:59 AM
        Target: f:\BarryAllen14\Unity Projects\My project\My project.sln

    OmniSharp server started.
        Path: c:\Users\SMME\.vscode\extensions\ms-dotnettools.csharp-1.25.2-win32-x64\.omnisharp\1.39.2\OmniSharp.exe
        PID: 8820

    [info]: OmniSharp.Stdio.Host
            Starting OmniSharp on Windows 6.2.9200.0 (x64)
    [info]: OmniSharp.Services.DotNetCliService
            Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
    [info]: OmniSharp.Services.DotNetCliService
            Using the 'dotnet' on the PATH.
    [info]: OmniSharp.Services.DotNetCliService
            DotNetPath set to dotnet
    [info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
            Located 1 MSBuild instance(s)
                1: Visual Studio Build Tools 2022 17.4.33205.214 17.4.1 - "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin"
    [info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
            Registered MSBuild instance: Visual Studio Build Tools 2022 17.4.33205.214 17.4.1 - "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin"
    [info]: OmniSharp.WorkspaceInitializer
            Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
    [info]: OmniSharp.Cake.CakeProjectSystem
            Detecting Cake files in 'f:\BarryAllen14\Unity Projects\My project'.
    [info]: OmniSharp.Cake.CakeProjectSystem
            Did not find any Cake files
    [info]: OmniSharp.MSBuild.ProjectSystem
            Detecting projects in 'f:\BarryAllen14\Unity Projects\My project\My project.sln'.
    [info]: OmniSharp.MSBuild.ProjectManager
            Queue project update for 'f:\BarryAllen14\Unity Projects\My project\Assembly-CSharp.csproj'
    [info]: OmniSharp.Script.ScriptProjectSystem
            Detecting CSX files in 'f:\BarryAllen14\Unity Projects\My project'.
    [info]: OmniSharp.Script.ScriptProjectSystem
            Did not find any CSX files
    [info]: OmniSharp.WorkspaceInitializer
            Configuration finished.
    [info]: OmniSharp.Stdio.Host
            Omnisharp server running using Stdio at location 'f:\BarryAllen14\Unity Projects\My project' on host 16560.
    [info]: OmniSharp.MSBuild.ProjectManager
            Loading project: f:\BarryAllen14\Unity Projects\My project\Assembly-CSharp.csproj
    [info]: OmniSharp.MSBuild.ProjectManager
            Successfully loaded project file 'f:\BarryAllen14\Unity Projects\My project\Assembly-CSharp.csproj'.
    [info]: OmniSharp.MSBuild.ProjectManager
            Adding project 'f:\BarryAllen14\Unity Projects\My project\Assembly-CSharp.csproj'
    [info]: OmniSharp.MSBuild.ProjectManager
            Update project: Assembly-CSharp

** This is my Assembly-CSharp.csproj file.**

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup>
        <LangVersion>9.0</LangVersion>
      </PropertyGroup>
      <PropertyGroup>
        <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
        <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
        <ProductVersion>10.0.20506</ProductVersion>
        <SchemaVersion>2.0</SchemaVersion>
        <RootNamespace></RootNamespace>
        <ProjectGuid>{e6bdc332-25e1-2831-82c1-25d0441455a3}</ProjectGuid>
        <OutputType>Library</OutputType>
        <AppDesignerFolder>Properties</AppDesignerFolder>
        <AssemblyName>Assembly-CSharp</AssemblyName>
        <TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
        <FileAlignment>512</FileAlignment>
        <BaseDirectory>.</BaseDirectory>
      </PropertyGroup>
      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
        <DebugSymbols>true</DebugSymbols>
        <DebugType>full</DebugType>
        <Optimize>false</Optimize>
        <OutputPath>Temp\bin\Debug\</OutputPath>
        <DefineConstants>DEBUG;TRACE;UNITY_2021_3_16;UNITY_2021_3;UNITY_2021;UNITY_5_3_OR_NEWER;UNITY_5_4_OR_NEWER;UNITY_5_5_OR_NEWER;UNITY_5_6_OR_NEWER;UNITY_2017_1_OR_NEWER;UNITY_2017_2_OR_NEWER;UNITY_2017_3_OR_NEWER;UNITY_2017_4_OR_NEWER;UNITY_2018_1_OR_NEWER;UNITY_2018_2_OR_NEWER;UNITY_2018_3_OR_NEWER;UNITY_2018_4_OR_NEWER;UNITY_2019_1_OR_NEWER;UNITY_2019_2_OR_NEWER;UNITY_2019_3_OR_NEWER;UNITY_2019_4_OR_NEWER;UNITY_2020_1_OR_NEWER;UNITY_2020_2_OR_NEWER;UNITY_2020_3_OR_NEWER;UNITY_2021_1_OR_NEWER;UNITY_2021_2_OR_NEWER;UNITY_2021_3_OR_NEWER;PLATFORM_ARCH_64;UNITY_64;UNITY_INCLUDE_TESTS;ENABLE_AR;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_EVENT_QUEUE;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_TEXTURE_STREAMING;ENABLE_VIRTUALTEXTURING;ENABLE_UNET;ENABLE_LZMA;ENABLE_UNITYEVENTS;ENABLE_VR;ENABLE_WEBCAM;ENABLE_UNITYWEBREQUEST;ENABLE_WWW;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_COLLAB;ENABLE_CLOUD_SERVICES_COLLAB_SOFTLOCKS;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_SERVICES_USE_WEBREQUEST;ENABLE_CLOUD_SERVICES_CRASH_REPORTING;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_LICENSE;ENABLE_EDITOR_HUB_LICENSE;ENABLE_WEBSOCKET_CLIENT;ENABLE_DIRECTOR_AUDIO;ENABLE_DIRECTOR_TEXTURE;ENABLE_MANAGED_JOBS;ENABLE_MANAGED_TRANSFORM_JOBS;ENABLE_MANAGED_ANIMATION_JOBS;ENABLE_MANAGED_AUDIO_JOBS;ENABLE_MANAGED_UNITYTLS;INCLUDE_DYNAMIC_GI;ENABLE_SCRIPTING_GC_WBARRIERS;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;ENABLE_VIDEO;ENABLE_ACCELERATOR_CLIENT_DEBUGGING;PLATFORM_STANDALONE;TEXTCORE_1_0_OR_NEWER;PLATFORM_STANDALONE_WIN;UNITY_STANDALONE_WIN;UNITY_STANDALONE;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_NVIDIA;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_UNITY_GAME_SERVICES_ANALYTICS_SUPPORT;ENABLE_OUT_OF_PROCESS_CRASH_HANDLER;ENABLE_CLUSTER_SYNC;ENABLE_CLUSTERINPUT;PLATFORM_UPDATES_TIME_OUTSIDE_OF_PLAYER_LOOP;GFXDEVICE_WAITFOREVENT_MESSAGEPUMP;ENABLE_WEBSOCKET_HOST;ENABLE_MONO;NET_STANDARD_2_0;NET_STANDARD;NET_STANDARD_2_1;NETSTANDARD;NETSTANDARD2_1;ENABLE_PROFILER;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_WIN;ENABLE_UNITY_COLLECTIONS_CHECKS;ENABLE_BURST_AOT;UNITY_TEAM_LICENSE;UNITY_PRO_LICENSE;ENABLE_CUSTOM_RENDER_TEXTURE;ENABLE_DIRECTOR;ENABLE_LOCALIZATION;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_TILEMAP;ENABLE_TIMELINE;ENABLE_LEGACY_INPUT_MANAGER;TEXTCORE_FONT_ENGINE_1_5_OR_NEWER;CSHARP_7_OR_LATER;CSHARP_7_3_OR_NEWER</DefineConstants>
        <ErrorReport>prompt</ErrorReport>
        <WarningLevel>4</WarningLevel>
        <NoWarn>0169</NoWarn>
        <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
      </PropertyGroup>
      <PropertyGroup>
        <NoConfig>true</NoConfig>
        <NoStdLib>true</NoStdLib>
        <AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
        <ImplicitlyExpandNETStandardFacades>false</ImplicitlyExpandNETStandardFacades>
        <ImplicitlyExpandDesignTimeFacades>false</ImplicitlyExpandDesignTimeFacades>
      </PropertyGroup>
      <ItemGroup>
         <Compile Include="Assets\abc.cs" />
        <Reference Include="UnityEngine">
            <HintPath>C:\Program Files\Unity\Hub\Editor\2021.3.16f1\Editor\Data\Managed\UnityEngine\UnityEngine.dll</HintPath>
        </Reference>
        <Reference Include="UnityEngine.AIModule">
            <HintPath>C:\Program Files\Unity\Hub\Editor\2021.3.16f1\Editor\Data\Managed\UnityEngine\UnityEngine.AIModule.dll</HintPath>
        </Reference>
        <Reference Include="UnityEngine.ARModule">
            <HintPath>C:\Program Files\Unity\Hub\Editor\2021.3.16f1\Editor\Data\Managed\UnityEngine\UnityEngine.ARModule.dll</HintPath>
        </Reference>
        <Reference Include="UnityEngine.AccessibilityModule">
            <HintPath>C:\Program Files\Unity\Hub\Editor\2021.3.16f1\Editor\Data\Managed\UnityEngine\UnityEngine.AccessibilityModule.dll</HintPath>
        </Reference>
        <Reference Include="UnityEngine.AndroidJNIModule">
            <HintPath>C:\Program Files\Unity\Hub\Editor\2021.3.16f1\Editor\Data\Managed\UnityEngine\UnityEngine.AndroidJNIModule.dll</HintPath>
        </Reference>
        <Reference Include="UnityEngine.AnimationModule">
            <HintPath>C:\Program Files\Unity\Hub\Editor\2021.3.16f1\Editor\Data\Managed\UnityEngine\UnityEngine.AnimationModule.dll</HintPath>
        </Reference>
        <Reference Include="UnityEngine.AssetBundleModule">
            <HintPath>C:\Program Files\Unity\Hub\Editor\2021.3.16f1\Editor\Data\Managed\UnityEngine\UnityEngine.AssetBundleModule.dll</HintPath>
        </Reference>
        <Reference Include="UnityEngine.AudioModule">
            <HintPath>C:\Program Files\Unity\Hub\Editor\2021.3.16f1\Editor\Data\Managed\UnityEngine\UnityEngine.AudioModule.dll</HintPath>
        </Reference>
        <Reference Include="UnityEngine.ClothModule">
            <HintPath>C:\Program Files\Unity\Hub\Editor\2021.3.16f1\Editor\Data\Managed\UnityEngine\UnityEngine.ClothModule.dll</HintPath>
        </Reference>
        <Reference Include="UnityEngine.ClusterInputModule">
            <HintPath>C:\Program Files\Unity\Hub\Editor\2021.3.16f1\Editor\Data\Managed\UnityEngine\UnityEngine.ClusterInputModule.dll</HintPath>
        </Reference>
        <Reference Include="UnityEngine.ClusterRendererModule">
            <HintPath>C:\Program Files\Unity\Hub\Editor\2021.3.16f1\Editor\Data\Managed\UnityEngineth>
        </Reference>

        <Reference Include="Unity.VisualScripting.Core">
            <HintPath>F:\BarryAllen14\Unity Projects\My project\Library\ScriptAssemblies\Unity.VisualScripting.Core.dll</HintPath>
        </Reference>
        <Reference Include="Unity.EditorCoroutines.Editor">
            <HintPath>F:\BarryAllen14\Unity Projects\My project\Library\ScriptAssemblies\Unity.EditorCoroutines.Editor.dll</HintPath>
        </Reference>
        <Reference Include="Unity.Services.Core.Analytics">
            <HintPath>F:\BarryAllen14\Unity Projects\My project\Library\ScriptAssemblies\Unity.Services.Core.Analytics.dll</HintPath>
        </Reference>
        <Reference Include="Unity.VisualScripting.Shared.Editor">
            <HintPath>F:\BarryAllen14\Unity Projects\My project\Library\ScriptAssemblies\Unity.VisualScripting.Shared.Editor.dll</HintPath>
        </Reference>
        <Reference Include="Unity.Services.Core.Environments">
            <HintPath>F:\BarryAllen14\Unity Projects\My project\Library\ScriptAssemblies\Unity.Services.Core.Environments.dll</HintPath>
        </Reference>
        <Reference Include="Unity.Timeline.Editor">
            <HintPath>F:\BarryAllen14\Unity Projects\My project\Library\ScriptAssemblies\Unity.Timeline.Editor.dll</HintPath>
        </Reference>
        <Reference Include="Unity.TestTools.CodeCoverage.Editor">
            <HintPath>F:\BarryAllen14\Unity Projects\My project\Library\ScriptAssemblies\Unity.TestTools.CodeCoverage.Editor.dll</HintPath>
        </Reference>
        <Reference Include="Unity.VisualScripting.State">
            <HintPath>F:\BarryAllen14\Unity Projects\My project\Library\ScriptAssemblies\Unity.VisualScripting.State.dll</HintPath>
        </Reference>
      </ItemGroup>
      <ItemGroup>
      </ItemGroup>
      <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

    </Project>

`
when I click Project loading Failed at the bottom of the screen. Assembly-CSharp.csproj status file opens with following text.
.

This happens with every project I create both new one and old one.
Originally I was following pathway from my unity learn, when i treid to use **onTriggerEnter **function vscode didnt autocomplete it, so manually typed it. But i didnt work like it is supposed to. vscode was treating it as user defined build function not as monobehaviour function. I searched for possible reasons on unity forums, stack exchange and reddit but none of the solution worked for me.
So uninstalled Unity, VScode and .net frameworks. And installed everyth from scratch following these two guides.

https://code.visualstudio.com/docs/other/unity
https://code.visualstudio.com/docs/languages/dotnet

Now my freshly installed Unity and VScode is not even loading project properly.

My 2 days has been wasted. plz help me.

I also psoted the same thing in unity forum and according to replies this is problem is more likely due to vscode not unity editor.


来源: stackexchange

问:
How to add watch to state variable from separate cubit?
I am new to flutter and trying to add a watch on a variable of a state.

Now from some FavoriteScreen cubit, if I had to watch this variable 'someKindOfList' which is present in ExploreLoaded state. How would I do it?

I tried the following:

```<code>class FavoriteScreen extends StatelessWidget {
  const FavoriteScreen({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
      final List items = context.watch<ExploreCubit>().state.someKindOfList <== THIS IS NOT POSSIBLE...
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I am new to flutter and trying to add a watch on a variable of a state.

Now from some FavoriteScreen cubit, if I had to watch this variable 'someKindOfList' which is present in ExploreLoaded state. How would I do it?

I tried the following:

class FavoriteScreen extends StatelessWidget {
  const FavoriteScreen({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
      final List items = context.watch<ExploreCubit>().state.someKindOfList <== THIS IS NOT POSSIBLE...


问:
How can I Increase the Limit for the File Size in the Firebase Storage?
I created the chat using Firebase and React with sending image system.

And When I'm tryinng to upload an image that has more than 250KB, it giving and error in terminal:
error #1: GET https://firebasestorage.googleapis.com/v0/b/fatuber-1f4b8.appspot.com/o/25630189-72af-4cb5-990d-54c137f1aca4 404
error #2: Uncaught (in promise) FirebaseError: Firebase Storage: Object '25630189-72af-4cb5-990d-54c137f1aca4' does not exist. (storage/object-not-found)

How can I increase the Limit for the File Size in the Firebase storage?

Input.js File with sending system.

```<code>import React, { useContext, useState } from "react";
import Img from "../../static/chat/add-img.png";
import Attach from "../../static/chat/attach.png";
import { AuthContext } from "./AuthContext";
import { ChatContext } from "./ChatContext";
import {
  arrayUnion,
  doc,
  serverTimestamp,
  Timestamp,
  updateDoc,
} from "firebase/firestore";
import { db, storage } from "../../firebase";
import { v4 as uuid } from "uuid";
import { getDownloadURL, ref, uploadBytesResumable } from "firebase/storage";

const Input = () => {
  const [text, setText] = useState("");
  const [img, setImg] = useState(null);
  const { currentUser } = useContext(AuthContext);
  const { data } = useContext(ChatContext);

  const handleSend = async () => {
    if (img) {
      const storageRef = ref(storage, uuid());

      const uploadTask = uploadBytesResumable(storageRef, img);

      uploadTask.on(
        (error) => {
          //TODO:Handle Error
        },
        () => {
          getDownloadURL(uploadTask.snapshot.ref).then(async (downloadURL) => {
            await updateDoc(doc(db, "chats", data.chatId), {
              messages: arrayUnion({
                id: uuid(),
                text,
                senderId: currentUser.uid,
                date: Timestamp.now(),
                img: downloadURL,
              }),
            });
          });
        }
      );
    } else {
      await updateDoc(doc(db, "chats", data.chatId), {
        messages: arrayUnion({
          id: uuid(),
          text,
          senderId: currentUser.uid,
          date: Timestamp.now(),
        }),
      });
    }

    await updateDoc(doc(db, "userChats", currentUser.uid), {
      [data.chatId + ".lastMessage"]: {
        text,
      },
      [data.chatId + ".date"]: serverTimestamp(),
    });

    await updateDoc(doc(db, "userChats", data.user.uid), {
      [data.chatId + ".lastMessage"]: {
        text,
      },
      [data.chatId + ".date"]: serverTimestamp(),
    });

    setText("");
    setImg(null);
  };
  return (
    <div className="input">
      <input
        type="text"
        placeholder="Type something..."
        onChange={(e) => setText(e.target.value)}
        value={text}
      />
      <div className="send">
        <img src={Attach} alt="" />
        <input
          type="file"
          style={{ display: "none" }}
          id="file"
          onChange={(e) => setImg(e.target.files[0])}
        />
        <label htmlFor="file">
          <img src={Img} alt="" />
        </label>
        <button onClick={handleSend}>Send</button>
      </div>
    </div>
  );
};

export default Input;
</code>```

Body:
I created the chat using Firebase and React with sending image system.

And When I'm tryinng to upload an image that has more than 250KB, it giving and error in terminal:
error #1: GET https://firebasestorage.googleapis.com/v0/b/fatuber-1f4b8.appspot.com/o/25630189-72af-4cb5-990d-54c137f1aca4 404
error #2: Uncaught (in promise) FirebaseError: Firebase Storage: Object '25630189-72af-4cb5-990d-54c137f1aca4' does not exist. (storage/object-not-found)

How can I increase the Limit for the File Size in the Firebase storage?

Input.js File with sending system.

import React, { useContext, useState } from "react";
import Img from "../../static/chat/add-img.png";
import Attach from "../../static/chat/attach.png";
import { AuthContext } from "./AuthContext";
import { ChatContext } from "./ChatContext";
import {
  arrayUnion,
  doc,
  serverTimestamp,
  Timestamp,
  updateDoc,
} from "firebase/firestore";
import { db, storage } from "../../firebase";
import { v4 as uuid } from "uuid";
import { getDownloadURL, ref, uploadBytesResumable } from "firebase/storage";

const Input = () => {
  const [text, setText] = useState("");
  const [img, setImg] = useState(null);
  const { currentUser } = useContext(AuthContext);
  const { data } = useContext(ChatContext);

  const handleSend = async () => {
    if (img) {
      const storageRef = ref(storage, uuid());

      const uploadTask = uploadBytesResumable(storageRef, img);

      uploadTask.on(
        (error) => {
          //TODO:Handle Error
        },
        () => {
          getDownloadURL(uploadTask.snapshot.ref).then(async (downloadURL) => {
            await updateDoc(doc(db, "chats", data.chatId), {
              messages: arrayUnion({
                id: uuid(),
                text,
                senderId: currentUser.uid,
                date: Timestamp.now(),
                img: downloadURL,
              }),
            });
          });
        }
      );
    } else {
      await updateDoc(doc(db, "chats", data.chatId), {
        messages: arrayUnion({
          id: uuid(),
          text,
          senderId: currentUser.uid,
          date: Timestamp.now(),
        }),
      });
    }

    await updateDoc(doc(db, "userChats", currentUser.uid), {
      [data.chatId + ".lastMessage"]: {
        text,
      },
      [data.chatId + ".date"]: serverTimestamp(),
    });

    await updateDoc(doc(db, "userChats", data.user.uid), {
      [data.chatId + ".lastMessage"]: {
        text,
      },
      [data.chatId + ".date"]: serverTimestamp(),
    });

    setText("");
    setImg(null);
  };
  return (

      <input
        type="text"
        placeholder="Type something..."
        onChange={(e) => setText(e.target.value)}
        value={text}
      />

        <input
          type="file"
          style={{ display: "none" }}
          id="file"
          onChange={(e) => setImg(e.target.files[0])}
        />

        <button onClick={handleSend}>Send</button>

  );
};

export default Input;


问:
Creating Self-signed Certificate Chain with openssl
I trying to create a Self-signed certificate chain for simulations, but when I try to import the server's certificate it looks like it's not part of the chain.

Here is what I did:

Creating a Private key:

openssl genrsa -out RootCA.key 4096

Creating a new Certificate and sign it with the previous private key:

openssl req -new -x509 -days 1826 -key RootCA.key -out RootCA.crt

Create a new Private key for Intermediate:

openssl genrsa -out IntermediateCA.key 4096

Create a Certificate Signing Request for the Intermediate's certificate:

openssl req -new -key IntermediateCA.key -out IntermediateCA.csr

Create a certificate from the CSR and sign it with the private key of the Root CA:

openssl x509 -req -days 1000 -in IntermediateCA.csr -CA RootCA.crt -CAkey RootCA.key -CAcreateserial -out IntermediateCA.crt

Add the new Certificate of Root CA to trusted host of your operation system:

cp *.crt /usr/local/share/ca-certificates/

Update-ca-certificates

Create a new private key for a server:

openssl genrsa -out server.key 4096

Create a new Certificate Signing Request for the server's certificate:

Note: this common name field on the request must match the FQDN of the server.

openssl req -new -key server.key -out server.csr

Create a certificate from the CSR and sign it with the private key of the Intermediate CA:

openssl x509 -req -in server.csr -CA IntermediateCA.crt -CAkey IntermediateCA.key -set_serial 0101 -out server.crt -days 500 -sha1

But it looks like isolated certificates:

Commands-Results

And I would like to simulate this:

Expected-Results

OpenSSL Print:

% openssl x509 -text -in server.pem
Certificate:
    Data:
        Version: 1 (0x0)
        Serial Number: 101 (0x65)
    Signature Algorithm: sha1WithRSAEncryption
        Issuer: C=IL, O=new, CN=yoyo
        Validity
            Not Before: Dec 15 08:49:53 2022 GMT
            Not After : Apr 28 08:49:53 2024 GMT
        Subject: C=IL, O=new, CN=server
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
                RSA Public-Key: (4096 bit)
                Modulus:
                    00:c6:ab:06:38:e9:10:11:64:6f:62:53:07:37:12:
                    66:4f:02:88:6c:b6:a1:b0:57:c0:5b:49:67:f1:b8:
                    78:90:d0:c3:44:bc:d0:94:e7:24:4b:01:41:43:d1:
                    6d:e5:ff:4f:6d:79:52:39:e6:c9:f6:5c:ba:4b:0c:
                    8f:a2:3a:dd:de:d5:a6:13:36:4c:d3:dc:7c:3b:59:
                    19:1d:19:05:8c:18:1b:0c:5d:2d:b2:0c:5a:1c:00:
                    b4:fe:4c:de:55:10:15:81:9e:3c:c9:db:be:ac:a5:
                    a4:cc:a9:8b:79:f9:d6:43:96:aa:35:1e:ad:50:c3:
                    3b:0f:35:af:97:a7:fb:30:8e:ac:fe:8c:9e:45:23:
                    17:9b:e2:19:16:f2:fe:bb:8e:c4:7f:37:ee:99:34:
                    2c:bf:f8:a4:8a:30:c9:bc:80:4a:f5:ce:38:72:be:
                    67:7e:7e:b7:45:93:95:5f:fd:5b:19:86:d0:c4:f4:
                    e5:4b:ed:e9:48:ef:4d:6a:a1:d4:72:ae:69:1d:20:
                    71:2b:5e:30:a5:b0:19:5a:96:0c:ab:49:d3:92:59:
                    46:df:26:ce:94:8c:e9:3d:e2:3d:ac:67:00:ad:e6:
                    6f:dc:06:67:f8:45:8d:13:78:3a:2e:20:b5:80:c4:
                    27:e1:a3:c9:da:1e:ac:23:78:63:02:02:41:7e:d3:
                    75:d2:86:22:b3:dd:e8:85:eb:6f:ec:da:d2:1d:be:
                    a4:a9:36:41:95:0f:08:07:a8:0a:56:4c:d0:60:e1:
                    ff:a5:ce:c7:02:63:6b:96:5c:90:45:79:2b:aa:c0:
                    db:91:6d:92:31:d7:62:25:e9:bf:40:78:a6:14:da:
                    51:67:e2:84:86:b7:7a:f2:d7:7b:11:50:92:1f:3d:
                    57:6c:c7:13:a9:67:d1:66:f1:4a:cd:ec:89:e3:e2:
                    45:ab:26:bf:ad:35:c2:89:14:c4:10:a9:7b:4e:71:
                    f7:e2:53:28:81:8c:32:fd:70:90:77:9e:30:c9:3d:
                    59:08:bb:00:7c:81:3e:48:10:5a:f1:2c:88:6d:97:
                    0e:c0:8e:31:82:c4:85:af:6c:fc:50:1a:70:a1:b2:
                    33:2e:92:b6:93:df:fb:49:b0:11:d6:00:b7:f9:cf:
                    60:61:53:c9:78:a8:5c:45:3c:b5:6c:8c:dc:8c:7e:
                    61:6e:77:65:c2:38:90:7a:69:08:2c:e2:43:88:f8:
                    1e:31:da:4b:dd:d4:e2:b7:34:d5:ba:23:27:f2:9a:
                    00:56:55:93:d3:3c:f6:ee:26:15:82:79:60:08:46:
                    4a:15:88:2e:ce:57:2e:41:7a:51:83:5b:de:a3:28:
                    33:c1:f2:54:c9:05:a7:ea:6a:60:3c:93:ea:9a:eb:
                    3a:0a:5f
                Exponent: 65537 (0x10001)
    Signature Algorithm: sha1WithRSAEncryption
         9c:c2:fe:e2:6c:7b:6c:bb:7c:be:01:91:41:4c:67:3c:2b:1f:
         94:8e:05:76:3b:89:f2:4c:7f:e7:b8:93:1e:f1:6c:15:59:f0:
         c9:71:3a:79:9f:c5:59:cc:2d:1a:54:fa:0a:2b:ed:71:db:17:
         bf:4e:9b:d2:a7:ce:a0:58:4a:29:66:b7:88:69:d9:a7:74:75:
         33:43:4c:b1:d4:2f:13:1c:e8:d3:92:df:2c:81:31:52:37:76:
         0b:12:70:6a:e4:9b:4d:6a:80:a6:52:e5:23:54:78:f4:2f:8d:
         34:62:89:41:68:f1:0d:b1:3e:5b:1c:01:3e:26:f4:f5:b3:0e:
         b4:e2:58:ac:70:c9:61:e5:11:a3:45:32:69:73:7f:bc:da:4c:
         be:31:0d:c2:6b:6a:34:83:0e:e8:a9:15:c5:ce:9b:87:2b:2b:
         2b:69:67:54:5f:12:e2:7c:8d:d2:6b:de:20:42:6d:94:82:74:
         15:8c:71:a3:22:03:0c:16:e6:64:9a:08:1d:3d:58:df:2b:91:
         74:d1:12:ec:46:b4:7f:f5:13:4a:ba:50:b7:51:3b:cc:dd:e8:
         36:60:d3:20:41:4a:41:a0:89:22:fc:80:d8:99:e9:67:da:5d:
         f0:e6:f3:26:d2:a3:e6:e8:a9:69:30:df:53:10:b5:4f:0d:94:
         0b:eb:bd:1c:ff:d9:1d:ab:db:92:ae:5a:aa:7a:84:6f:62:b3:
         5f:71:71:cc:ad:6a:bd:af:84:2f:b0:cd:6a:00:6e:4a:06:fa:
         19:04:60:46:34:cb:5f:b8:25:9d:8b:36:ea:e3:09:11:1c:61:
         73:30:5c:fd:7d:b4:e9:ad:d1:ad:63:61:91:fc:49:da:03:9b:
         00:01:91:c2:a3:bc:97:a3:0d:14:bf:a8:5e:36:4e:7c:6f:3d:
         d3:8a:49:23:e7:1e:d1:67:9d:4a:fe:32:53:2e:df:5c:d3:49:
         3e:17:8d:03:9d:0d:08:26:40:9a:da:79:46:c9:84:f9:1b:09:
         3b:44:f7:3f:b8:76:20:4a:15:eb:88:8b:be:00:25:18:3f:e3:
         65:dc:a2:d7:80:81:bd:21:53:da:b2:eb:9f:43:f6:a7:41:1a:
         65:f5:4f:7f:8d:3d:3d:f9:7e:d9:17:15:68:a4:df:03:40:7f:
         ec:bd:77:4f:94:4f:8b:38:2f:1e:80:b8:e9:40:c5:cf:d5:86:
         28:e6:20:42:91:58:94:6d:0c:9e:9e:e6:dd:2f:4c:82:50:70:
         f3:d7:aa:b0:6f:a7:23:16:08:1f:a9:cf:69:32:40:ae:2e:51:
         11:2d:dd:80:9a:df:88:ec:82:b0:f4:04:d9:66:80:99:b5:38:
         87:0e:03:3d:6f:f3:90:b8
-----BEGIN CERTIFICATE-----
MIIEyjCCArICAWUwDQYJKoZIhvcNAQEFBQAwKjELMAkGA1UEBhMCSUwxDDAKBgNV
BAoMA25ldzENMAsGA1UEAwwEeW95bzAeFw0yMjEyMTUwODQ5NTNaFw0yNDA0Mjgw
ODQ5NTNaMCwxCzAJBgNVBAYTAklMMQwwCgYDVQQKDANuZXcxDzANBgNVBAMMBnNl
cnZlcjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMarBjjpEBFkb2JT
BzcSZk8CiGy2obBXwFtJZ/G4eJDQw0S80JTnJEsBQUPRbeX/T215UjnmyfZcuksM
j6I63d7VphM2TNPcfDtZGR0ZBYwYGwxdLbIMWhwAtP5M3lUQFYGePMnbvqylpMyp
i3n51kOWqjUerVDDOw81r5en+zCOrP6MnkUjF5viGRby/ruOxH837pk0LL/4pIow
ybyASvXOOHK+Z35+t0WTlV/9WxmG0MT05Uvt6UjvTWqh1HKuaR0gcSteMKWwGVqW
DKtJ05JZRt8mzpSM6T3iPaxnAK3mb9wGZ/hFjRN4Oi4gtYDEJ+GjydoerCN4YwIC
QX7TddKGIrPd6IXrb+za0h2+pKk2QZUPCAeoClZM0GDh/6XOxwJja5ZckEV5K6rA
25FtkjHXYiXpv0B4phTaUWfihIa3evLXexFQkh89V2zHE6ln0WbxSs3siePiRasm
v601wokUxBCpe05x9+JTKIGMMv1wkHeeMMk9WQi7AHyBPkgQWvEsiG2XDsCOMYLE
ha9s/FAacKGyMy6StpPf+0mwEdYAt/nPYGFTyXioXEU8tWyM3Ix+YW53ZcI4kHpp
CCziQ4j4HjHaS93U4rc01bojJ/KaAFZVk9M89u4mFYJ5YAhGShWILs5XLkF6UYNb
3qMoM8HyVMkFp+pqYDyT6prrOgpfAgMBAAEwDQYJKoZIhvcNAQEFBQADggIBAJzC
/uJse2y7fL4BkUFMZzwrH5SOBXY7ifJMf+e4kx7xbBVZ8MlxOnmfxVnMLRpU+gor
7XHbF79Om9KnzqBYSilmt4hp2ad0dTNDTLHULxMc6NOS3yyBMVI3dgsScGrkm01q
gKZS5SNUePQvjTRiiUFo8Q2xPlscAT4m9PWzDrTiWKxwyWHlEaNFMmlzf7zaTL4x
DcJrajSDDuipFcXOm4crKytpZ1RfEuJ8jdJr3iBCbZSCdBWMcaMiAwwW5mSaCB09
WN8rkXTREuxGtH/1E0q6ULdRO8zd6DZg0yBBSkGgiSL8gNiZ6WfaXfDm8ybSo+bo
qWkw31MQtU8NlAvrvRz/2R2r25KuWqp6hG9is19xccytar2vhC+wzWoAbkoG+hkE
YEY0y1+4JZ2LNurjCREcYXMwXP19tOmt0a1jYZH8SdoDmwABkcKjvJejDRS/qF42
TnxvPdOKSSPnHtFnnUr+MlMu31zTST4XjQOdDQgmQJraeUbJhPkbCTtE9z+4diBK
FeuIi74AJRg/42XcoteAgb0hU9qy659D9qdBGmX1T3+NPT35ftkXFWik3wNAf+y9
d0+UT4s4Lx6AuOlAxc/VhijmIEKRWJRtDJ6e5t0vTIJQcPPXqrBvpyMWCB+pz2ky
QK4uUREt3YCa34jsgrD0BNlmgJm1OIcOAz1v85C4
-----END CERTIFICATE-----```


问:
Typescript + webpack cannot build scss module
I have the typescript, webpack and scss working properly, and want to bring it to the next level by enabling modules. Here is what I have:

in declaration.d.ts:

```<code>declare module '*.module.scss' {
  const classes: { readonly [key: string]: string };
  export default classes;
}
</code>```

In webpack.config.js:

```<code>{
        test: /.module.(sass|scss)$/,
        exclude: /node_modules/,
        use: [
          'style-loader',
          'css-modules-typescript-loader',
          {
            loader: 'css-loader',
            options: {
              modules: true,
            },
          },
          'sass-loader',
        ],
      },
</code>```

And then in the test.module.scss, I have:

```<code>.testStyle {
    color: red;
}
</code>```

Finally in the .tsx code:

```<code>import styles from './test.module.scss';

<div className={styles.testStyle}>hello</div>
</code>```

However when I try to build it, it start giving me weird error:

```<code>ERROR in ./src/ui/test.module.scss (./node_modules/css-modules-typescript-loader/index.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].use[2]!./node_modules/sass-loader/dist/cjs.js!./node_modules/style-loader/dist/cjs.js!./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/ui/test.module.scss)
Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: expected "{".
  ╷
2 │       import API from "!../../../../node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js";
  │                                                                                ^
  ╵
  src\ui\test.module.scss 2:104  root stylesheet
SassError: SassError: expected "{".
  ╷
2 │       import API from "!../../../../node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js";
  │                                                                                ^
  ╵
  src\ui\test.module.scss 2:104  root stylesheet
    at Object.loader (C:\dev\codes\dsde\frontend-dsde\node_modules\sass-loader\dist\index.js:69:14)
 @ ./src/ui/test.module.scss 8:6-417 22:17-24 26:0-387 26:0-387 27:22-29 27:33-47 27:50-64
 @ ./src/ui/test.tsx 2:0-54 3:73-94
 @ ./src/index.tsx 7:0-55 79:43-57
</code>```

My hinge is the loaders didn't work properly, but I don't see anything wrong with my webpack config...

Body:
I have the typescript, webpack and scss working properly, and want to bring it to the next level by enabling modules. Here is what I have:

in declaration.d.ts:

declare module '*.module.scss' {
  const classes: { readonly [key: string]: string };
  export default classes;
}

In webpack.config.js:

{
        test: /.module.(sass|scss)$/,
        exclude: /node_modules/,
        use: [
          'style-loader',
          'css-modules-typescript-loader',
          {
            loader: 'css-loader',
            options: {
              modules: true,
            },
          },
          'sass-loader',
        ],
      },

And then in the test.module.scss, I have:

.testStyle {
    color: red;
}

Finally in the .tsx code:

import styles from './test.module.scss';

hello

However when I try to build it, it start giving me weird error:

ERROR in ./src/ui/test.module.scss (./node_modules/css-modules-typescript-loader/index.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].use[2]!./node_modules/sass-loader/dist/cjs.js!./node_modules/style-loader/dist/cjs.js!./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/ui/test.module.scss)
Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: expected "{".
  ╷
2 │       import API from "!../../../../node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js";
  │                                                                                ^
  ╵
  src\ui\test.module.scss 2:104  root stylesheet
SassError: SassError: expected "{".
  ╷
2 │       import API from "!../../../../node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js";
  │                                                                                ^
  ╵
  src\ui\test.module.scss 2:104  root stylesheet
    at Object.loader (C:\dev\codes\dsde\frontend-dsde\node_modules\sass-loader\dist\index.js:69:14)
 @ ./src/ui/test.module.scss 8:6-417 22:17-24 26:0-387 26:0-387 27:22-29 27:33-47 27:50-64
 @ ./src/ui/test.tsx 2:0-54 3:73-94
 @ ./src/index.tsx 7:0-55 79:43-57

My hinge is the loaders didn't work properly, but I don't see anything wrong with my webpack config...


问:
How do I issue an alert and restart the application if the function is running too long?
There is a calculator that works through expo.There is a function that performs counting. However, if you enter a very large expression with a factorial there, for example, the calculator will hang tightly, as in the case, for example, if the counting function works for more than 3-5s and does not produce a result, issue an error and restart / throw it out of the application

```<code> const getResult = () => {

        return (<TextInput
                onContentSizeChange={x => {
                    //console.log(x)
                }}
                editable={true}
                style={styles.expression}
                multiline={true}
                keyboardType={"number-pad"}
                textAlign="right"
                textAlignVertical="top"

            >{highlight(expr)}</TextInput>

        )

    }

    const Display = () =>
        <View style={styles.display}>
            {}

                {getResult()}

            {}
        </View>
</code>```

Here is the function itself that returns the result
I tried to do
Put

```<code>var t0 = performance.now();
</code>```

before GetResult()
and

```<code>

     var t1 = performance.now();
    if (t1-t0>0.01) {

        BackHandler.exitApp();

    }

    console.log("Call to doSomething took " + ( t1-t0) + " milliseconds.")

</code>```

after Display(), however, when the application freezes, it does not return the end time of the function, so exiting the application does not work, please help fix it.

Body:
There is a calculator that works through expo.There is a function that performs counting. However, if you enter a very large expression with a factorial there, for example, the calculator will hang tightly, as in the case, for example, if the counting function works for more than 3-5s and does not produce a result, issue an error and restart / throw it out of the application

 const getResult = () => {

        return (<TextInput
                onContentSizeChange={x => {
                    //console.log(x)
                }}
                editable={true}
                style={styles.expression}
                multiline={true}
                keyboardType={"number-pad"}
                textAlign="right"
                textAlignVertical="top"

            >{highlight(expr)}</TextInput>

        )

    }

    const Display = () =>
        <View style={styles.display}>
            {}

                {getResult()}

            {}
        </View>

Here is the function itself that returns the result
I tried to do
Put

var t0 = performance.now();

before GetResult()
and

     var t1 = performance.now();
    if (t1-t0>0.01) {

        BackHandler.exitApp();

    }

    console.log("Call to doSomething took " + ( t1-t0) + " milliseconds.")

after Display(), however, when the application freezes, it does not return the end time of the function, so exiting the application does not work, please help fix it.


问:
How to check if a "webNavigation.onBeforeNavigate" page has been "navigated"
I'm working with a Chrome Extension developed in jQuery and I want to trigger a script each time some page is opened.

This script is listed in manifest.json:

```<code>
{
    "manifest_version": 2,
    ...
    "content_scripts": [
        {
            ...,
            "js": [
                "src/this_script.js",
                ...
            ]
        }
    ]
}
</code>```

It works OK when:

Clicking an external link with the proper URL of such page

Refreshing the page

Most of the times I click to its link from other pages on this site

However, sometimes this link appears at the site in a way that clicking to it does change the URL and the content but it does not trigger this_script.js.

I just need to know how to identify when an URL changes (e.g.: changeInfo.status === 'complete') doesn't triggers a webNavigation event.

With this I'd easly refresh the page with a simple location.href.

Regards,
Juan Vicente

Body:
I'm working with a Chrome Extension developed in jQuery and I want to trigger a script each time some page is opened.

This script is listed in manifest.json:

{
    "manifest_version": 2,
    ...
    "content_scripts": [
        {
            ...,
            "js": [
                "src/this_script.js",
                ...
            ]
        }
    ]
}

It works OK when:

Clicking an external link with the proper URL of such page

Refreshing the page

Most of the times I click to its link from other pages on this site

However, sometimes this link appears at the site in a way that clicking to it does change the URL and the content but it does not trigger this_script.js.

I just need to know how to identify when an URL changes (e.g.: changeInfo.status === 'complete') doesn't triggers a webNavigation event.

With this I'd easly refresh the page with a simple location.href.

Regards,
Juan Vicente


问:
LONG DISPLAY OF WALLET ADDRESS - FLEXBOX REACT NATIVE
I want to display long type of address which is described as truncated in the middle and still keep 4 last character of address, the address display will take the width of its container.

The example address is "3njkd323njkfne4342kj21s3sjkdfbjkb"

I tried to google it around, and I found a solution in the code and screen below.

But the problem is:

With width 40% or 50% or any width that can not include full address: it still has gap between 2 text component (pink and red), which I dont want to have.

With width 70% (which means it can show all the letters of address) it shows perfectly, no gap.

I thought the reason for the gap is because of the font of letters, depends on which character, or because it doesnt have enough space to include one more letter. I hope that you can understand the context I try to describe.

Im stuck for more than one week on this issue, if you have any idea or related keyword to this issues, I am really appreciate that.


问:
Use tkinter based PySimpleGUI as root user via pkexec
I want to show a GUI Window (PySimpleGUI which is based on tkinter) as root user.
I'm using pkexec for that. Using GNU/Linux Debian stable.

But I got the error

```<code>no display name and no $DISPLAY environment variable
</code>```

I understand that a bit. But I don't know how to solve it. I tried to set DISPLAY = ":0.0" but this doesn't work either.

```<code>couldn't connect to display ":0.0"
</code>```

This is my test call include setting DISPLAY.

```<code>pkexec python3 -c "import PySimpleGUI as sg;import os;os.environ['DISPLAY'] = ':0.0';sg.Window(title='title', layout=[[]], margins=(200, 100)).read()"
</code>```

This is the full error output

```<code>No protocol specified
No protocol specified
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.9/dist-packages/PySimpleGUI/PySimpleGUI.py", line 10075, in read
    results = self._read(timeout=timeout, timeout_key=timeout_key)
  File "/usr/local/lib/python3.9/dist-packages/PySimpleGUI/PySimpleGUI.py", line 10146, in _read
    self._Show()
  File "/usr/local/lib/python3.9/dist-packages/PySimpleGUI/PySimpleGUI.py", line 9886, in _Show
    StartupTK(self)
  File "/usr/local/lib/python3.9/dist-packages/PySimpleGUI/PySimpleGUI.py", line 16817, in StartupTK
    _get_hidden_master_root()
  File "/usr/local/lib/python3.9/dist-packages/PySimpleGUI/PySimpleGUI.py", line 16704, in _get_hidden_master_root
    Window.hidden_master_root = tk.Tk()
  File "/usr/lib/python3.9/tkinter/__init__.py", line 2270, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: couldn't connect to display ":0.0"
</code>```

Body:
I want to show a GUI Window (PySimpleGUI which is based on tkinter) as root user.
I'm using pkexec for that. Using GNU/Linux Debian stable.

But I got the error

no display name and no $DISPLAY environment variable

I understand that a bit. But I don't know how to solve it. I tried to set DISPLAY = ":0.0" but this doesn't work either.

couldn't connect to display ":0.0"

This is my test call include setting DISPLAY.

pkexec python3 -c "import PySimpleGUI as sg;import os;os.environ['DISPLAY'] = ':0.0';sg.Window(title='title', layout=[[]], margins=(200, 100)).read()"

This is the full error output

No protocol specified
No protocol specified
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.9/dist-packages/PySimpleGUI/PySimpleGUI.py", line 10075, in read
    results = self._read(timeout=timeout, timeout_key=timeout_key)
  File "/usr/local/lib/python3.9/dist-packages/PySimpleGUI/PySimpleGUI.py", line 10146, in _read
    self._Show()
  File "/usr/local/lib/python3.9/dist-packages/PySimpleGUI/PySimpleGUI.py", line 9886, in _Show
    StartupTK(self)
  File "/usr/local/lib/python3.9/dist-packages/PySimpleGUI/PySimpleGUI.py", line 16817, in StartupTK
    _get_hidden_master_root()
  File "/usr/local/lib/python3.9/dist-packages/PySimpleGUI/PySimpleGUI.py", line 16704, in _get_hidden_master_root
    Window.hidden_master_root = tk.Tk()
  File "/usr/lib/python3.9/tkinter/__init__.py", line 2270, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: couldn't connect to display ":0.0"


问:
Error: Cannot find module '@utils' after compile Typescript
I am currently create a express-typescript boilerplate for myself and this is what i didnt expect because i build this boilerplate base on another boilerplate is express-typescript-starter

```<code>> Error: Cannot find module '@utils'
> Require stack:
> C:\Users\xflas\OneDrive\Documents\Personal Projects\Boilerplate\my-boilerplate\dist\app.js
> C:\Users\xflas\OneDrive\Documents\Personal Projects\Boilerplate\my-boilerplate\dist\server.js
</code>```

And this is my tsconfig.json

```<code>{
    "compileOnSave": false,
    "compilerOptions": {
        "target": "es2017",
        "lib": [
            "es2017",
            "esnext.asynciterable"
        ],
        "typeRoots": [
            "node_modules/@types"
        ],
        "allowSyntheticDefaultImports": true,
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "forceConsistentCasingInFileNames": true,
        "moduleResolution": "node",
        "module": "commonjs",
        "pretty": true,
        "sourceMap": true,
        "declaration": true,
        "outDir": "dist",
        "allowJs": true,
        "noEmit": false,
        "esModuleInterop": true,
        "resolveJsonModule": true,
        "importHelpers": true,
        "baseUrl": "src",
        "paths": {
            "@/*": [
                "*"
            ],
            "@config": [
                "config"
            ],
            "@controllers": [
                "controllers"
            ],
            "@dtos": [
                "models/dtos"
            ],
            "@exceptions": [
                "exceptions"
            ],
            "@interfaces": [
                "interfaces"
            ],
            "@middlewares": [
                "middlewares"
            ],
            "@models": [
                "models"
            ],
            "@routes": [
                "routes"
            ],
            "@services": [
                "services"
            ],
            "@utils": [
                "utils"
            ]
        }
    },
    "include": [
        "src/**/*.ts",
        "src/**/*.json",
        ".env"
    ],
    "exclude": [
        "node_modules",
        "src/http",
        "src/logs",
        "src/tests"
    ]
}

</code>```

My app.ts

```<code>import express from 'express';
import hpp from 'hpp';
import helmet from 'helmet';
import morgan from 'morgan';
import cors from 'cors';
import swaggerJSDoc from 'swagger-jsdoc';
import swaggerUi from 'swagger-ui-express';
import cookieParser from 'cookie-parser';
import { IRoute } from '@interfaces';
import { logger, stream } from '@utils';
import { errorMiddleware } from '@middlewares';
import { Database } from '@models';
import config from '@config';

export default class App {
  public app: express.Application;
  public env: string;
  public port: string | number;

  constructor(routes: IRoute[]) {
    this.app = express();
    this.env = config.NODE_ENV || 'development';
    this.port = config.SERVER.PORT || 8080;

    this.connectToDatabase();
    this.initializeMiddlewares();
    this.initializeRoutes(routes);
    this.initializeSwagger();
    this.initializeErrorHandling();
  }

  private connectToDatabase() {
    Database.sequelize.sync({ force: false });
  }

  public listen() {
    this.app.listen(this.port, () => {
      logger.info(`=================================`);
      logger.info(`======= ENV: ${this.env} =======`);
      logger.info(` App listening on the port ${this.port}`);
      logger.info(`=================================`);
    });
  }

  public getServer() {
    return this.app;
  }

  private initializeMiddlewares() {
    this.app.use(morgan(config.LOG_FORMAT, { stream }));
    this.app.use(cors({ origin: config.ORIGIN, credentials: config.CREDENTIALS }));
    this.app.use(hpp());
    this.app.use(helmet());
    this.app.use(express.json());
    this.app.use(express.urlencoded({ extended: true }));
    this.app.use(cookieParser());
  }

  private initializeRoutes(routes: IRoute[]) {
    routes.forEach(route => {
      this.app.use('/', route.router);
    });
  }

  private initializeSwagger() {
    const options = {
      definition: {
        openapi: '3.0.0',
        info: {
          title: 'Express API for Boilerplate',
          version: '1.0.0',
          description: 'Express Boilerplate API Docs',
        },
      },
      apis: ['swagger.yaml'],
    };
    const specs = swaggerJSDoc(options);
    this.app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(specs));
  }

  private initializeErrorHandling() {
    this.app.use(errorMiddleware);
  }
}

</code>```

Thank you so much

I tried to delete the node_modules and try to edit the tsconfig.json with types: ["node"] but it not working

Body:
I am currently create a express-typescript boilerplate for myself and this is what i didnt expect because i build this boilerplate base on another boilerplate is express-typescript-starter

> Error: Cannot find module '@utils'
> Require stack:
> C:\Users\xflas\OneDrive\Documents\Personal Projects\Boilerplate\my-boilerplate\dist\app.js
> C:\Users\xflas\OneDrive\Documents\Personal Projects\Boilerplate\my-boilerplate\dist\server.js

And this is my tsconfig.json

{
    "compileOnSave": false,
    "compilerOptions": {
        "target": "es2017",
        "lib": [
            "es2017",
            "esnext.asynciterable"
        ],
        "typeRoots": [
            "node_modules/@types"
        ],
        "allowSyntheticDefaultImports": true,
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "forceConsistentCasingInFileNames": true,
        "moduleResolution": "node",
        "module": "commonjs",
        "pretty": true,
        "sourceMap": true,
        "declaration": true,
        "outDir": "dist",
        "allowJs": true,
        "noEmit": false,
        "esModuleInterop": true,
        "resolveJsonModule": true,
        "importHelpers": true,
        "baseUrl": "src",
        "paths": {
            "@/*": [
                "*"
            ],
            "@config": [
                "config"
            ],
            "@controllers": [
                "controllers"
            ],
            "@dtos": [
                "models/dtos"
            ],
            "@exceptions": [
                "exceptions"
            ],
            "@interfaces": [
                "interfaces"
            ],
            "@middlewares": [
                "middlewares"
            ],
            "@models": [
                "models"
            ],
            "@routes": [
                "routes"
            ],
            "@services": [
                "services"
            ],
            "@utils": [
                "utils"
            ]
        }
    },
    "include": [
        "src/**/*.ts",
        "src/**/*.json",
        ".env"
    ],
    "exclude": [
        "node_modules",
        "src/http",
        "src/logs",
        "src/tests"
    ]
}

My app.ts

import express from 'express';
import hpp from 'hpp';
import helmet from 'helmet';
import morgan from 'morgan';
import cors from 'cors';
import swaggerJSDoc from 'swagger-jsdoc';
import swaggerUi from 'swagger-ui-express';
import cookieParser from 'cookie-parser';
import { IRoute } from '@interfaces';
import { logger, stream } from '@utils';
import { errorMiddleware } from '@middlewares';
import { Database } from '@models';
import config from '@config';

export default class App {
  public app: express.Application;
  public env: string;
  public port: string | number;

  constructor(routes: IRoute[]) {
    this.app = express();
    this.env = config.NODE_ENV || 'development';
    this.port = config.SERVER.PORT || 8080;

    this.connectToDatabase();
    this.initializeMiddlewares();
    this.initializeRoutes(routes);
    this.initializeSwagger();
    this.initializeErrorHandling();
  }

  private connectToDatabase() {
    Database.sequelize.sync({ force: false });
  }

  public listen() {
    this.app.listen(this.port, () => {
      logger.info(`=================================`);
      logger.info(`======= ENV: ${this.env} =======`);
      logger.info(` App listening on the port ${this.port}`);
      logger.info(`=================================`);
    });
  }

  public getServer() {
    return this.app;
  }

  private initializeMiddlewares() {
    this.app.use(morgan(config.LOG_FORMAT, { stream }));
    this.app.use(cors({ origin: config.ORIGIN, credentials: config.CREDENTIALS }));
    this.app.use(hpp());
    this.app.use(helmet());
    this.app.use(express.json());
    this.app.use(express.urlencoded({ extended: true }));
    this.app.use(cookieParser());
  }

  private initializeRoutes(routes: IRoute[]) {
    routes.forEach(route => {
      this.app.use('/', route.router);
    });
  }

  private initializeSwagger() {
    const options = {
      definition: {
        openapi: '3.0.0',
        info: {
          title: 'Express API for Boilerplate',
          version: '1.0.0',
          description: 'Express Boilerplate API Docs',
        },
      },
      apis: ['swagger.yaml'],
    };
    const specs = swaggerJSDoc(options);
    this.app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(specs));
  }

  private initializeErrorHandling() {
    this.app.use(errorMiddleware);
  }
}

Thank you so much

I tried to delete the node_modules and try to edit the tsconfig.json with types: ["node"] but it not working


问:
How to draw a rectangle when a mouse is dragged?
I'm trying to draw a rectangle onto a selected image when a mouse is dragged.
It seems that mouse listener is working but a rectangle is not drawn along the mouse drag.

What my program will do is, open an image selection dialog when a "click" buttom is pressed then select an image(any). After the image is displayed on a new JPanel, click a mouse and drag it to draw a rectangle on the image.

If there is a better way to code the function, please tell me how, It will be much appreciated.

```<code>
import java.awt.BorderLayout;
import java.awt.Graphics;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.Color;

import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;

@SuppressWarnings("serial")
public class Test extends JFrame {
    private JPanel panel;
    private GridBagLayout gbl;
    private GridBagConstraints gbc;
    private Rectangle draggingRectangle;
    private boolean dragging;

    public Test() {
        dragging = false;
        constructPanel();
    }

    private void constructPanel() {
        setBounds(0, 0, 400, 300);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        panel = new JPanel();
        gbl = new GridBagLayout();
        panel.setLayout(gbl);
        gbc = new GridBagConstraints();

        JButton imageButton = new JButton("Click");
        imageButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                JFileChooser jc = new JFileChooser();
                jc.setFileSelectionMode(JFileChooser.FILES_ONLY);
                if (jc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
                    displayImage(jc.getSelectedFile().getAbsolutePath());
                } else {
                    return;
                }
            }
        });
        gbc.gridx = 1;
        gbc.gridy = 1;
        gbl.setConstraints(imageButton, gbc);
        panel.add(imageButton);
        getContentPane().add(panel, BorderLayout.CENTER);
    }

    private void displayImage(String filePath) {
        draggingRectangle = new Rectangle(0, 0);
        dragging = false;

        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                JScrollPane scrPane = null;
                try {
                    JPanel imagePanel = new JPanel() {
                        public void paintComponent(Graphics g) {
                            super.paintComponent(g);
                            g.drawImage(Toolkit.getDefaultToolkit().getImage(filePath), 0, 0, this);

                            // g.setXORMode(Color.WHITE);
                            g.setColor(Color.WHITE);
                            if (dragging) {
                                g.drawRect(draggingRectangle.x, draggingRectangle.y, draggingRectangle.width,
                                        draggingRectangle.height);
                            }
                        }
                    };
                    scrPane = new JScrollPane(imagePanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

                    scrPane.addMouseListener(new MouseListener() {

                        @Override
                        public void mouseClicked(MouseEvent e) {
                            // TODO Auto-generated method stub

                        }

                        @Override
                        public void mousePressed(MouseEvent e) {
                            if (draggingRectangle != null) {
                                System.out.println("pressed");
                                draggingRectangle.setBounds(e.getX(), e.getY(), 0, 0);
                                imagePanel.repaint();
                            }
                        }

                        @Override
                        public void mouseReleased(MouseEvent e) {
                            dragging = false;
                            if (draggingRectangle != null) {
                                System.out.println("released");
                                draggingRectangle.setBounds(0, 0, 0, 0);
                                imagePanel.repaint();
                            }
                        }

                        @Override
                        public void mouseEntered(MouseEvent e) {
                            // TODO Auto-generated method stub

                        }

                        @Override
                        public void mouseExited(MouseEvent e) {
                            // TODO Auto-generated method stub

                        }

                    });

                    scrPane.addMouseMotionListener(new MouseMotionListener() {

                        @Override
                        public void mouseDragged(MouseEvent e) {
                            if (draggingRectangle != null) {
                                System.out.println("dragged");
                                int x = (int) draggingRectangle.getX();
                                int y = (int) draggingRectangle.getY();
                                draggingRectangle.setSize(e.getX() - x, e.getY() - y);
                                imagePanel.repaint();
                            }
                        }

                        @Override
                        public void mouseMoved(MouseEvent e) {
                            // TODO Auto-generated method stub

                        }

                    });
                } catch (Exception e) {
                    // TODO: handle exception
                }

                JFrame imageDisplay = new JFrame();
                imageDisplay.add(scrPane);
                imageDisplay.setSize(530, 200);
                imageDisplay.setVisible(true);
            }
        });
    }

    public static void main(String[] args) {
        new Test().setVisible(true);
    }
}

</code>```

I inserted a debug code to check whether the mouse listener is working.
and it's working.

Body:
I'm trying to draw a rectangle onto a selected image when a mouse is dragged.
It seems that mouse listener is working but a rectangle is not drawn along the mouse drag.

What my program will do is, open an image selection dialog when a "click" buttom is pressed then select an image(any). After the image is displayed on a new JPanel, click a mouse and drag it to draw a rectangle on the image.

If there is a better way to code the function, please tell me how, It will be much appreciated.

import java.awt.BorderLayout;
import java.awt.Graphics;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.Color;

import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;

@SuppressWarnings("serial")
public class Test extends JFrame {
    private JPanel panel;
    private GridBagLayout gbl;
    private GridBagConstraints gbc;
    private Rectangle draggingRectangle;
    private boolean dragging;

    public Test() {
        dragging = false;
        constructPanel();
    }

    private void constructPanel() {
        setBounds(0, 0, 400, 300);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        panel = new JPanel();
        gbl = new GridBagLayout();
        panel.setLayout(gbl);
        gbc = new GridBagConstraints();

        JButton imageButton = new JButton("Click");
        imageButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                JFileChooser jc = new JFileChooser();
                jc.setFileSelectionMode(JFileChooser.FILES_ONLY);
                if (jc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
                    displayImage(jc.getSelectedFile().getAbsolutePath());
                } else {
                    return;
                }
            }
        });
        gbc.gridx = 1;
        gbc.gridy = 1;
        gbl.setConstraints(imageButton, gbc);
        panel.add(imageButton);
        getContentPane().add(panel, BorderLayout.CENTER);
    }

    private void displayImage(String filePath) {
        draggingRectangle = new Rectangle(0, 0);
        dragging = false;

        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                JScrollPane scrPane = null;
                try {
                    JPanel imagePanel = new JPanel() {
                        public void paintComponent(Graphics g) {
                            super.paintComponent(g);
                            g.drawImage(Toolkit.getDefaultToolkit().getImage(filePath), 0, 0, this);

                            // g.setXORMode(Color.WHITE);
                            g.setColor(Color.WHITE);
                            if (dragging) {
                                g.drawRect(draggingRectangle.x, draggingRectangle.y, draggingRectangle.width,
                                        draggingRectangle.height);
                            }
                        }
                    };
                    scrPane = new JScrollPane(imagePanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

                    scrPane.addMouseListener(new MouseListener() {

                        @Override
                        public void mouseClicked(MouseEvent e) {
                            // TODO Auto-generated method stub

                        }

                        @Override
                        public void mousePressed(MouseEvent e) {
                            if (draggingRectangle != null) {
                                System.out.println("pressed");
                                draggingRectangle.setBounds(e.getX(), e.getY(), 0, 0);
                                imagePanel.repaint();
                            }
                        }

                        @Override
                        public void mouseReleased(MouseEvent e) {
                            dragging = false;
                            if (draggingRectangle != null) {
                                System.out.println("released");
                                draggingRectangle.setBounds(0, 0, 0, 0);
                                imagePanel.repaint();
                            }
                        }

                        @Override
                        public void mouseEntered(MouseEvent e) {
                            // TODO Auto-generated method stub

                        }

                        @Override
                        public void mouseExited(MouseEvent e) {
                            // TODO Auto-generated method stub

                        }

                    });

                    scrPane.addMouseMotionListener(new MouseMotionListener() {

                        @Override
                        public void mouseDragged(MouseEvent e) {
                            if (draggingRectangle != null) {
                                System.out.println("dragged");
                                int x = (int) draggingRectangle.getX();
                                int y = (int) draggingRectangle.getY();
                                draggingRectangle.setSize(e.getX() - x, e.getY() - y);
                                imagePanel.repaint();
                            }
                        }

                        @Override
                        public void mouseMoved(MouseEvent e) {
                            // TODO Auto-generated method stub

                        }

                    });
                } catch (Exception e) {
                    // TODO: handle exception
                }

                JFrame imageDisplay = new JFrame();
                imageDisplay.add(scrPane);
                imageDisplay.setSize(530, 200);
                imageDisplay.setVisible(true);
            }
        });
    }

    public static void main(String[] args) {
        new Test().setVisible(true);
    }
}

I inserted a debug code to check whether the mouse listener is working.
and it's working.


问:
Can't stop listening on local ip SimpleTCP [C#]
So I have my form1.cs and a different class called TCP-Control.cs. This is the tcpcontrol below. The form1 buttons clicks just simple call these methods.

public SimpleTcpServer voidRayServer = new SimpleTcpServer();

public void ServerOffline()
{
    voidRayServer.Stop();
}

public void ServerOnline()
{
    Form1 warpGate1 = new Form1();

    string ipAdress = warpGate1.IPAdress;
    string port = warpGate1.ServerPort;

    IPAddress ip = IPAddress.Parse(ipAdress);

    voidRayServer.Start(ip, Convert.ToInt32(port));
    warpGate1.TextBoxStatus += "hey";
}
```
<p>I call these methods from form1 and starting the server is no problem. But I have now tried everything and I can't get the listening to stop with the <code>ServerOffline()</code> method. The crazy thing is if I try doing</p>
<pre class="lang-cs prettyprint-override"><code>voidRayServer.Start();
</code>```

and immediately after

voidRayServer.Stop();
```
<p>the server stops and I can see it's not listening in cmd with the <code>netstat -ano</code> command.</p>
<p>I am completely out of ideas and this feels like it's so simple yet it's not working. I don't want to do:</p>
<pre class="lang-cs prettyprint-override"><code>Application.Restart();
</code>```

Because that would close the port but it looks bad for a program in my opinion.

Body:
So I have my form1.cs and a different class called TCP-Control.cs. This is the tcpcontrol below. The form1 buttons clicks just simple call these methods.

public SimpleTcpServer voidRayServer = new SimpleTcpServer();

public void ServerOffline()
{
    voidRayServer.Stop();
}

public void ServerOnline()
{
    Form1 warpGate1 = new Form1();

    string ipAdress = warpGate1.IPAdress;
    string port = warpGate1.ServerPort;

    IPAddress ip = IPAddress.Parse(ipAdress);

    voidRayServer.Start(ip, Convert.ToInt32(port));
    warpGate1.TextBoxStatus += "hey";
}

I call these methods from form1 and starting the server is no problem. But I have now tried everything and I can't get the listening to stop with the ServerOffline() method. The crazy thing is if I try doing

voidRayServer.Start();

and immediately after

voidRayServer.Stop();

the server stops and I can see it's not listening in cmd with the netstat -ano command.

I am completely out of ideas and this feels like it's so simple yet it's not working. I don't want to do:

Application.Restart();

Because that would close the port but it looks bad for a program in my opinion.


问:
Populating a QTableWidget in a PyQt5 GUI with a result returned from a stored procedure in MySQL
I have made a GUI in PyQt5 that allows you to deal with a database. There is an insert button which allows you to insert data into a database and then using a stored procedure whose parameter is a MySQL query in string format, it passes a select query to the stored procedure whose where clause consists of values just entered.

`

```<code>    def insert(self):
        try:
            self.table.setRowCount(0)
            QEmpID = self.lineEmpID.text() + "%"
            QFName = self.lineFName.text() + "%"
            QLName = self.lineLName .text() + "%"
            QSalary = self.lineSalary.text() + "%"
            QTask = self.lineTask.text() + "%"
            mydb = mc.connect(host="localhost",username="root",password="",database="Office")
            mycursor = mydb.cursor()
            selectQuery = "SELECT * From Employee WHERE EmpID like '{}' and FirstName like '{}' and LastName like '{}' and Salary like '{}' and Task like '{}'".format(QEmpID, QFName,QLName,QSalary,QTask)
            QEmpID = self.lineEmpID.text()
            QFName = self.lineFName.text()
            QLName = self.lineLName.text()
            QSalary = self.lineSalary.text()
            QTask = self.lineTask.text()
            insertQuery = "INSERT INTO Employee Values({},'{}','{}',{},'{}')".format(QEmpID,QFName, QLName, QSalary, QTask)
            mycursor.execute(insertQuery)
            mydb.commit()
            insertResult = mycursor.fetchall()
            mycursor.callProc('fetchData',[selectQuery])

            for result in mycursor.stored_results():
                selectResult = result.fetchall()

            for row_number,row_data in enumerate(selectResult):
                self.table.insertRow(row_number)
                for column_number,data in enumerate(row_data):
                    self.table.setItem(row_number,column_number,QTableWidgetItem(str(data)))

        except mc.Error as e:
            print(e)
</code>```

The above is my python code for the insert function which is then connected to the insert button.

`

```<code>DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `fetchData`(in query1 varchar(1000))
begin
    set @q = query1;
    PREPARE stmt from @q;
    EXECUTE stmt;
    DEALLOCATE PREPARE stmt;
end$$
DELIMITER ;

</code>```

The above is my stored procedure which executes a query passed to it in string format.

However, when I type in the record to be inserted into the fields and then press Insert, the following shows up without any tracebacks or error reports in the IDLE Shell:

The thing is, the record does get inserted into the database and I think the issue is with the calling of stored procedure with a select query passed to it and whose result can then be populated into the QTableWidget.

I can't think of anything right now. Help is needed.

Thank you!

Body:
I have made a GUI in PyQt5 that allows you to deal with a database. There is an insert button which allows you to insert data into a database and then using a stored procedure whose parameter is a MySQL query in string format, it passes a select query to the stored procedure whose where clause consists of values just entered.

`

    def insert(self):
        try:
            self.table.setRowCount(0)
            QEmpID = self.lineEmpID.text() + "%"
            QFName = self.lineFName.text() + "%"
            QLName = self.lineLName .text() + "%"
            QSalary = self.lineSalary.text() + "%"
            QTask = self.lineTask.text() + "%"
            mydb = mc.connect(host="localhost",username="root",password="",database="Office")
            mycursor = mydb.cursor()
            selectQuery = "SELECT * From Employee WHERE EmpID like '{}' and FirstName like '{}' and LastName like '{}' and Salary like '{}' and Task like '{}'".format(QEmpID, QFName,QLName,QSalary,QTask)
            QEmpID = self.lineEmpID.text()
            QFName = self.lineFName.text()
            QLName = self.lineLName.text()
            QSalary = self.lineSalary.text()
            QTask = self.lineTask.text()
            insertQuery = "INSERT INTO Employee Values({},'{}','{}',{},'{}')".format(QEmpID,QFName, QLName, QSalary, QTask)
            mycursor.execute(insertQuery)
            mydb.commit()
            insertResult = mycursor.fetchall()
            mycursor.callProc('fetchData',[selectQuery])

            for result in mycursor.stored_results():
                selectResult = result.fetchall()

            for row_number,row_data in enumerate(selectResult):
                self.table.insertRow(row_number)
                for column_number,data in enumerate(row_data):
                    self.table.setItem(row_number,column_number,QTableWidgetItem(str(data)))

        except mc.Error as e:
            print(e)

The above is my python code for the insert function which is then connected to the insert button.

`

DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `fetchData`(in query1 varchar(1000))
begin
    set @q = query1;
    PREPARE stmt from @q;
    EXECUTE stmt;
    DEALLOCATE PREPARE stmt;
end$$
DELIMITER ;

The above is my stored procedure which executes a query passed to it in string format.

However, when I type in the record to be inserted into the fields and then press Insert, the following shows up without any tracebacks or error reports in the IDLE Shell:

The thing is, the record does get inserted into the database and I think the issue is with the calling of stored procedure with a select query passed to it and whose result can then be populated into the QTableWidget.

I can't think of anything right now. Help is needed.

Thank you!


问:
WooCommerce "Used for variations" check by default
I would like the checkbox on the WooCommerce add product form called 'Used for variations' to be checked by default. I have search everywhere but cannot find out how to do this.