Hark Dand
Hark Dand
CC#
Created by Hark Dand on 5/31/2024 in #help
[SOLVED] .NET runtime control over tty input and output
I am currently doing some experiments writing a console application in C#. I am trying to get a noncanonical/raw tty while using C#. Since ttys are not a C# specific concept, I followed the approach one would normally take in C: utilising termios to disable some tty attributes and to apply them. I am doing this by using some platform invocations to the libc library. Setting the attributes works as expected; no errors and all the attributes I expect to be deactivated are deactivated. Here comes the issue, however: using termios I intentionally disabled the option the let the tty process inputs such as CTRL+C. I would expect, then, that pressing CTRL+C when running the binary does not stop the application; unfortunately, it does. I also disabled - again, via termios - that input is only read line-wise. It should, instead, be read character-wise. However, input only gets read when I enter a newline character. I have tried this exact same configuration in C, where it works flawlessly. My question then is: What additional pre-processing does the .NET runtime add to a console application and its standard I/O? I am well aware that I can configure some of the behaviour I described earlier by setting properties on the Console class. However, that does not give me the control I want over the tty.
11 replies
CC#
Created by Hark Dand on 2/13/2023 in #help
✅ Indexer return collection or single object depending on parameter
Hi all, is there any way to selectively return either a single object or a collection of multiple objects depending on the given parameter? I want to achieve the following behavior: Let's say I have some class which references a table by Rows (alphabetically, e.g. A, B, C, ...) and Columns (numerically, e.g. 1, 2, 3, ...) If I want to have a reference to the cell A1 I would write the following:
public void SomeMethod()
{
var returnedObject = someClass["A1"]
}
public void SomeMethod()
{
var returnedObject = someClass["A1"]
}
Additionally, I would also like to be able to give ranges as the index. For example:
public void SomeMethod() {
var returnedObjectCollection = someClass["A1:A11"]
foreach (var o in returnedObjectCollection)
{
// Do something here...
}
}
public void SomeMethod() {
var returnedObjectCollection = someClass["A1:A11"]
foreach (var o in returnedObjectCollection)
{
// Do something here...
}
}
Is there any way of achieving such a behaviour? Thank you very much for your help!
44 replies
CC#
Created by Hark Dand on 2/5/2023 in #help
✅ Set up SpecFlow Logging with 2 different projects
Currently I am trying to do some logging while using the SpecFlow BDD framework. In my solutions I have 2 projects setup (generic names): Project and Project.Specs. Project.Specs is home to the SpecFlow part of my solution. I have my Dependencies setup so that Project.Specs has a reference to Project. All fine and dandy, but I'm struggling to get a Logging tool going. SpecFlow has some documentation on how to use its Output API (https://docs.specflow.org/projects/specflow/en/latest/outputapi/outputapi.html) when only using a single project - at least that's what I'm getting from the documentation. Example: Say I've got a class called Personin Project and a Feature for it in my Project.Specs. I want to have some logging done in a method inside of Person. However, I do not know how this setup would look like in a 2-project-solution. I have also tried using NLog but to no avail. It did not cause any errors but it didn't work either. Thank you very much!
9 replies