Xan.Nava
Xan.Nava
CC#
Created by Xan.Nava on 10/6/2023 in #help
❔ Which C# nethost file to include in c++ host application
I am fallowing this tutorial on how to create a nethost application(c++) for .net applications. I am targeting .net 8.0, and have downloaded the sdk but am a bit confused on where to find the nethost file and what to actually include(.dll/.lib/.h)? For example I have found
C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Host.win-x64\8.0.0-rc.1.23419.4\runtimes\win-x64\native
C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Host.win-x64\8.0.0-rc.1.23419.4\runtimes\win-x64\native
though not sure if the pack is correct. I saw there were some for Maui, and some just .Net.Runtime for Mono and WebAssembly. and some with a Emscripten. I want to for now just use a console application for both c++ and C# sides. I see the .NETCore packs have my .net 8.0 as an option. Is them being called .NETCore just a wierd naming thing on microsofts side(from the .net Core vs .net Framework times)?
8 replies
CC#
Created by Xan.Nava on 5/17/2023 in #help
❔ Who to unify data access within a program.
For a quick bacground. I like being able to see where things are happening. If something is "hiding(AKA I can't inspect the code and see what it is calling)" connections through fancy practices I consider a code smell. Likewise How data is accessed should be clear in my opinion. Receiving data shouldn't change the data's state. There are more protocols for external data, like accessing data bases, or APIs, but I haven't seen a good protocol/framework for within a program. There are some guidelines programmers fallow that help, like naming conventions. Some have performance hits, just as I imagine other protocols do. Have any of you made/used protocols for within a program?
15 replies
CC#
Created by Xan.Nava on 11/15/2022 in #help
❔ Target runtime doesn't support default interface implementation.
As the title says. My csproj file https://pastebin.com/wFbwGJDn I am trying to use this in unity which supports this feature on 2022.2b. The documentation for unity says it is using the fallowing. https://docs.unity3d.com/2022.2/Documentation/Manual/dotnetProfileSupport.html .NET Framework (any version) Supported
29 replies
CC#
Created by Xan.Nava on 11/3/2022 in #help
How to override virtual interface in an interface
So I know a virtual method has a base implementation for interfaces, but I want to override that in a second interface that implements that interface, as fallows.
public interface INeed<T> : INeed {
void /*.*/ Receive(
T value);

override virtual Type TypeNeeded() {
return typeof(T);
}
}

public interface INeed {
virtual Type TypeNeeded() {
return null;
}
}
public interface INeed<T> : INeed {
void /*.*/ Receive(
T value);

override virtual Type TypeNeeded() {
return typeof(T);
}
}

public interface INeed {
virtual Type TypeNeeded() {
return null;
}
}
The above gives me an error, and if I get rid of override it requires a new keyword. I could just leave it to what ever inherits it, but the functionality is very straight forward, and just need it sepperated from the generic class so I can use it in a more generic way.
23 replies
CC#
Created by Xan.Nava on 10/28/2022 in #help
How to call a static method form interface in a generic class.
So I have a class as bellow.
public interface ISetup<T, P> where T : class {
public static T /*.*/ Setup(T target, P args) {
return target;
}
}
public interface ISetup<T, P> where T : class {
public static T /*.*/ Setup(T target, P args) {
return target;
}
}
and then a second generic class.
public class ClassName<T, P> where T : class, ISetup<T, P>, new() {
public T MethodName(P setupArg) {
var holder = new T();
return ISetup<T, P>.Setup(holder, setupArg);
}
}
public class ClassName<T, P> where T : class, ISetup<T, P>, new() {
public T MethodName(P setupArg) {
var holder = new T();
return ISetup<T, P>.Setup(holder, setupArg);
}
}
but I am getting the error. https://learn.microsoft.com/en-us/dotnet/csharp/misc/cs0704?f1url=%3FappId%3Droslyn%26k%3Dk(CS0704) The problem is I can't directly call the type from a generic. Is there anyway to do this, or am I trying to do something C# just can't do?
13 replies
CC#
Created by Xan.Nava on 8/21/2022 in #help
How to use Tuple in generic class?
So I know you can use Tuple<Type, Func<object>> for example, but is there any way to just use (Type type, Func<Object> obj)? Or even give Tuple<> names so it isn't Item1, Item2? I imagine if this isn't implemented it has to do with how the () tuple works at compile, but I would think it is easy enough on compile time to just do .ToTuple() wherever it would be needed.
33 replies
CC#
Created by Xan.Nava on 8/15/2022 in #help
Combining func reference behavior [Answered]
If i combine func3 += func1 and func3 += func2 and then lets say func1 += someMethod Will func3 also have it added?
16 replies