ascpixi
ascpixi
CC#
Created by ascpixi on 7/21/2024 in #help
✅ Evaluating arbitrary XML in MSBuild?
Hi all! :cathi: Is there any way to evaluate some arbitrary XML in MSBuild - similarly to how you'd do it with <Import>, just without the need for a file? My use case is that I want to call into a script, e.g. python supply-props.py, which will supply dynamically-generated properties, targets, etc., based on a more sane build DSL, and then import those from the string that Exec returns. I know that I can write the output to a temporary file and then <Import> it, but doing it in-memory without the need for that would be much more elegant. Thanks in advance! :catlove:
13 replies
CC#
Created by ascpixi on 5/5/2024 in #help
`RoslynCodeTaskFactory` using an ancient version of .NET...?
Hiya all! :cathi: I'm trying to define an inline task with RoslynCodeTaskFactory, but it seems like the corelib that the factory uses is a bit old - for example, there's no System.Range, you can't split by strings (only by chars!), and even ProcessStartInfo.ArgumentList doesn't exist. How can I tell the factory to use a more reasonable version? I'm defining the task like this:
<UsingTask TaskName="Script"
TaskFactory="RoslynCodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll"
>
<ParameterGroup>
<Content ParameterType="System.String" Required="True"/>
<In ParameterType="System.String" Required="False"/>
</ParameterGroup>

<Task>
<Using Namespace="System"/>
<Using Namespace="System.Diagnostics"/>
<Using Namespace="System.Collections.Generic"/>

<Code Type="Fragment" Language="cs">
<![CDATA[
(lots of code... above Discord's character limit)
]]>
</Code>
</Task>
</UsingTask>
<UsingTask TaskName="Script"
TaskFactory="RoslynCodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll"
>
<ParameterGroup>
<Content ParameterType="System.String" Required="True"/>
<In ParameterType="System.String" Required="False"/>
</ParameterGroup>

<Task>
<Using Namespace="System"/>
<Using Namespace="System.Diagnostics"/>
<Using Namespace="System.Collections.Generic"/>

<Code Type="Fragment" Language="cs">
<![CDATA[
(lots of code... above Discord's character limit)
]]>
</Code>
</Task>
</UsingTask>
5 replies
CC#
Created by ascpixi on 8/28/2023 in #help
❔ Does the import-by-ordinal functionality of DllImport work under NAOT + DirectPInvoke?
12 replies
CC#
Created by ascpixi on 6/12/2023 in #help
❔ ✅ Unhandled Exception: EETypeRva:0x0017C798: Reflection_Disabled on startup?
Hi all! I'm trying to build an AOT-compiled project with reflection disabled, using <IlcDisableReflection>true</IlcDisableReflection>. However, I'm getting the following exception on startup:
Unhandled Exception: EETypeRva:0x0017C798: Reflection_Disabled
at Internal.Reflection.RuntimeTypeInfo.get_GUID() + 0x33
at SharpGenModuleInitializer.Initialize() + 0x3c9
at Internal.Runtime.CompilerHelpers.StartupCodeHelpers.RunInitializers(TypeManagerHandle, ReadyToRunSectionType) + 0x45
at Internal.Runtime.CompilerHelpers.StartupCodeHelpers.RunModuleInitializers() + 0x39
at [PROJECT NAME]!<BaseAddress>+0x128c3e
Unhandled Exception: EETypeRva:0x0017C798: Reflection_Disabled
at Internal.Reflection.RuntimeTypeInfo.get_GUID() + 0x33
at SharpGenModuleInitializer.Initialize() + 0x3c9
at Internal.Runtime.CompilerHelpers.StartupCodeHelpers.RunInitializers(TypeManagerHandle, ReadyToRunSectionType) + 0x45
at Internal.Runtime.CompilerHelpers.StartupCodeHelpers.RunModuleInitializers() + 0x39
at [PROJECT NAME]!<BaseAddress>+0x128c3e
The project compiles fine without IlcDisableReflection. This exception only appeared when I added GUI functionality to my project with the help of ImGui.NET. The NuGet packages I'm using are:
ImGui.NET
SixLabors.ImageSharp
Vortice.D3DCompiler
Vortice.Direct3D11
Vortice.DXGI
ImGui.NET
SixLabors.ImageSharp
Vortice.D3DCompiler
Vortice.Direct3D11
Vortice.DXGI
Can anyone help me out? Thanks in advance! catlove
76 replies
CC#
Created by ascpixi on 4/23/2023 in #help
❔ Any way to make VS work with shared project wildcards?
Hi everyone! catlurk I have a C# shared project in a solution, and its projitems file is defined as the following:
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)**\*.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)**\*.cs" />
</ItemGroup>
By default, Visual Studio adds each file to this XML file. This keeps causing merge conflicts, since VS doesn't even settle on the order of how it adds the files. catfacepalm MSBuild works fine with this, and works perfectly; no issues there. However, with VS, several issues arise: - when adding a file, it gets added to "Miscellaneous Files". In order to fix this, I have to: - exclude the file from the project - include the file - restart VS, not saving the projitems - again include the file - when removing a file, it removes all files. Probably because it associates the wildcard entry with the removed file, and removes said wildcard entry. This can realistically only be fixed by restarting VS, discarding the projitems changes it made, and then telling it to include any file. After this, it will refresh the project, reflecting that all C# files are included in the project. I don't want to use individual entries for each file because of the merge conflict issue I've mentioned earlier, but also because VS sometimes even fails at that - sometimes I just see unreferenced files that were supposed to be deleted, but just kinda... stuck around. With a wildcard, this at least solves that issue - but many more, more severe ones arise. How can I make VS work with such wildcards? I'm not sure whether I can even use a csproj, because I'm compiling under NAOT w/ no corlib (the std library is supplied by the shared project) and I don't want to mess around with any of the internal classlib functionality (unless there is a way to package in the whole project just like a shared one). Thanks in advance! catsip
8 replies
CC#
Created by ascpixi on 4/8/2023 in #help
✅ (solved!) "System.InvalidOperationException: Sequence contains no elements" error from Roslyn
46 replies
CC#
Created by ascpixi on 12/30/2022 in #help
❔ Documentation on the AOT runtime's internal type system (EEType)?
I'm trying to create my own operating system in C#, using the ZeroSharp repository (https://github.com/MichalStrehovsky/zerosharp) and looking to RoseOS (https://github.com/Michael-Kelley/RoseOS) for guidance. Right now, I'm implementing the core library (corelib), and I've encountered the EEType type. From my research, this type represents the type of an object internally, and is present in every System.Object instance. There is close to no documentation for this type, since it's used internally, and the only implementation I've seen on this is the one in CoreRT (https://github.com/dotnet/corert/blob/master/src/Common/src/Internal/Runtime/EEType.cs). I've tried documenting this type so I could understand it later on, but this has proven very difficult in practice. Is there any documentation written for this? Or is there any documentation that would help me with writing my own core library, including these internal runtime types? Thanks!
11 replies
CC#
Created by ascpixi on 11/27/2022 in #help
❔ ✅ Deserializing a JSON array that contains a derived type AND a base type with JSON.NET?
I have three classes:
ScratchTarget
├─ ScratchScene
└─ ScratchSprite
ScratchTarget
├─ ScratchScene
└─ ScratchSprite
ScratchTarget contains all common fields that ScratchScene and ScratchSprite will have; I know that all of the JSON array entries will have fields from that class. However, some objects will be of type ScratchScene, and some will be of type ScratchSprite. I have a isStage field in ScratchTarget that informs me of the type of said ScratchTarget. How would I go about deserializing such a JSON array to a List<ScratchTarget>, with the JSON.NET deserializer also converting the extra fields by picking either ScratchScene or ScratchSprite?
20 replies