Bubba
Bubba
Explore posts from servers
CC#
Created by Bubba on 10/15/2024 in #help
Issue installing NUnit
Hello, I have been trying to install NUnit to add unit tests to my main project. To do so, I created a new project on Rider. The file structure is the following: \ \MainProject.sln \MainProject.csproj \TestProject\TestProject.csproj MainProject.csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<ApplicationManifest>app.manifest</ApplicationManifest>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Avalonia" Version="11.1.0" />
<PackageReference Include="Avalonia.Desktop" Version="11.1.0" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.1.0" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.1.0" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.1.0" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.67" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="8.0.10" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
</ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<ApplicationManifest>app.manifest</ApplicationManifest>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Avalonia" Version="11.1.0" />
<PackageReference Include="Avalonia.Desktop" Version="11.1.0" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.1.0" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.1.0" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.1.0" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.67" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="8.0.10" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
</ItemGroup>
</Project>
25 replies
CC#
Created by Bubba on 10/6/2024 in #help
Async issue
Hi! I'm trying to perform an http get request in a graphical element of the Eto library. Thing is, my whole program freezes until the response is received and I'm unsure why.
...REST OF THE CODE...
public class Body : StackLayout
{
public Body()
{
Orientation = Orientation.Vertical;
Padding = 10;
Spacing = 10;

var label = new Label
{
Text = "Home page loading...",
Font = new Font(FontFamilies.Sans, 16),
VerticalAlignment = VerticalAlignment.Center
};

Task.Run(async () => await LoadHomePageAsync(label)));
}

private async Task LoadHomePageAsync(Label label)
{
var content = await RetrieveHomePageContentAsync();
label.Text = content;
}
...REST OF THE CODE...
public class Body : StackLayout
{
public Body()
{
Orientation = Orientation.Vertical;
Padding = 10;
Spacing = 10;

var label = new Label
{
Text = "Home page loading...",
Font = new Font(FontFamilies.Sans, 16),
VerticalAlignment = VerticalAlignment.Center
};

Task.Run(async () => await LoadHomePageAsync(label)));
}

private async Task LoadHomePageAsync(Label label)
{
var content = await RetrieveHomePageContentAsync();
label.Text = content;
}
The call is performed inside the Task.Run, did I do something wrong?
58 replies
CC#
Created by Bubba on 10/3/2024 in #help
✅ Use Sqlite in a C# project
Hello, I'm trying to use Sqlite for the first time but I'm getting the following error when creating a connection.
using System.Data.SQLite;
...
new SQLiteConnection(connectionString);
...
using System.Data.SQLite;
...
new SQLiteConnection(connectionString);
...
Unhandled exception. System.DllNotFoundException: Unable to load shared library 'SQLite.Interop.dll' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable:
...
Unhandled exception. System.DllNotFoundException: Unable to load shared library 'SQLite.Interop.dll' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable:
...
I installed the packages SQLite and System.Data.SQLite.Core using NuGet. Any idea? (Not sure if it's important but i'm on apple silicon)
3 replies
DIAdiscord.js - Imagine an app
Created by Bubba on 8/2/2023 in #djs-questions
Issue with the implementation of a custom TextInput class
Hello, I'm trying to implement the following class in order to create a TextInputBuilder without having to use setPlaceholder, setCustomId, etc when creating a new object
interface TextInputProps {
placeholder?: string;
customId?: string;
label?: string;
style?: TextInputStyle;
required?: boolean;
minLength?: number;
maxLength?: number;
}

class TextInput {

private text: TextInputBuilder;

constructor(props: TextInputProps) {
this.text = new TextInputBuilder();
this.setParameters(props);
}

public get(): TextInputBuilder {
return this.text;
}

private setParameters(props: TextInputProps) {
const functionsObject = {
'placeholder': this.text.setPlaceholder,
'customId': this.text.setCustomId,
'label': this.text.setLabel,
'style': this.text.setStyle,
'required': this.text.setRequired,
'minLength': this.text.setMinLength,
'maxLength': this.text.setMaxLength,
};

for (const [key, value] of Object.entries(props)) {
if (key && value) {
console.log(`key: ${key}, value: ${value}`);
functionsObject[key](value);
}
}
}
}
interface TextInputProps {
placeholder?: string;
customId?: string;
label?: string;
style?: TextInputStyle;
required?: boolean;
minLength?: number;
maxLength?: number;
}

class TextInput {

private text: TextInputBuilder;

constructor(props: TextInputProps) {
this.text = new TextInputBuilder();
this.setParameters(props);
}

public get(): TextInputBuilder {
return this.text;
}

private setParameters(props: TextInputProps) {
const functionsObject = {
'placeholder': this.text.setPlaceholder,
'customId': this.text.setCustomId,
'label': this.text.setLabel,
'style': this.text.setStyle,
'required': this.text.setRequired,
'minLength': this.text.setMinLength,
'maxLength': this.text.setMaxLength,
};

for (const [key, value] of Object.entries(props)) {
if (key && value) {
console.log(`key: ${key}, value: ${value}`);
functionsObject[key](value);
}
}
}
}
However I'm receiving the following error:
key: placeholder, value: Product name
PROJECT_PATH/node_modules/@discordjs/builders/src/components/textInput/TextInput.ts:107
this.data.placeholder = placeholderValidator.parse(placeholder);
^
TypeError: Cannot set properties of undefined (setting 'placeholder')
key: placeholder, value: Product name
PROJECT_PATH/node_modules/@discordjs/builders/src/components/textInput/TextInput.ts:107
this.data.placeholder = placeholderValidator.parse(placeholder);
^
TypeError: Cannot set properties of undefined (setting 'placeholder')
Any idea?
3 replies