by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 22:46
    dotnet-maestro[bot] commented #46127
  • 22:44
    ryzngard synchronize #45302
  • 22:41
    dotnet-maestro[bot] commented #46127
  • 22:36
    dotnet-maestro[bot] commented #46127
  • 22:32
    CyrusNajmabadi synchronize #46022
  • 22:31
    dotnet-maestro[bot] commented #46127
  • 22:29
    CyrusNajmabadi edited #46022
  • 22:29
    RikkiGibson edited #46577
  • 22:28
    jaredpar commented #46445
  • 22:26
    333fred edited #46573
  • 22:26
    dotnet-maestro[bot] commented #46127
  • 22:23
    jaredpar milestoned #46577
  • 22:23
    jaredpar assigned #46577
  • 22:21
    dotnet-maestro[bot] commented #46127
  • 22:21
    RikkiGibson edited #46577
  • 22:16
    dotnet-maestro[bot] commented #46127
  • 22:14
    RikkiGibson edited #46577
  • 22:10
    dotnet-maestro[bot] commented #46127
  • 22:07
    RikkiGibson labeled #46577
  • 22:07
    RikkiGibson labeled #46577
Joseph Musser
@jnm2
That's part of why I don't like !(a < b) for >=
CyrusNajmabadi
@CyrusNajmabadi
i personally disagree :)
Joseph Musser
@jnm2
it's actually observable if you're doing three-state logic
CyrusNajmabadi
@CyrusNajmabadi
that indicates to me a significant problem
Joseph Musser
@jnm2
I like things to be agnostic as possible
CyrusNajmabadi
@CyrusNajmabadi
i.e. if my != is not equivalent to !( ... == ...), then it's more likely than not that i have a deeper bug
so i'd prefer to just have the core logic in one place, and the higher lifted out of that
but htat's just me :)
Joseph Musser
@jnm2
!(a < b) for >= goes against C#'s lifted nullable operators
because (int?)null < (int?)null and (int?)null >= (int?)null are both false
You can call it a deeper bug but what it is is unconventional (three-state) logic
However, CompareTo explicitly is not allowed to play that game, so !(a < b) is absolutely fine
What worries me is ever using == for NRE prevention
SivaSannidhi
@sivasannidhi
Hi All What is the best way to Generate DLL from .CSProj(.Net Core( by using roslyn
Joseph Musser
@jnm2
@sivasannidhi You'll have to be more specific about what "generate DLL" means. CSharpCompilation.Emit(stream) is what Roslyn gives you. It writes the DLL to a writable stream that you provide. It doesn't write the DLL to the project bin folder.
You can do it in a few lines:
MSBuildLocator.RegisterDefaults();

using var workspace = MSBuildWorkspace.Create();
var project = await workspace.OpenProjectAsync(csprojPath);
var compilation = await project.GetCompilationAsync(CancellationToken.None);
var result = compilation.Emit(yourStream);
// Check result.Success, or look at errors, warnings, and info messages in result.Diagnostics
SivaSannidhi
@sivasannidhi
@jnm2 Thank you for response.i have read like MSBuildWorkspace won't support .net core projects is it correct?
Joseph Musser
@jnm2
It does support .NET Core projects. You will have to have a .NET Core SDK installed that can build the projects, though.
If you don't use MSBuildWorkspace, you'll have to parse the csproj yourself. It's not always easy but it might get you what you want.
It will certainly diverge in a lot of cases from what MSBuild would do with the csproj
Jan Kučera
@miloush
Hi! If in a generic method<T> I wanted T t = default; to mean 0 for int and null for reference types while having nullable on, do I understand correctly based on dotnet/csharplang#3771 that this is currently not possible?
CyrusNajmabadi
@CyrusNajmabadi
no, it will be possible. using T? t = default
(also possible with nullable on, with a warning)
Jan Kučera
@miloush
wouldn't T? become Nullable<T> for structs?
CyrusNajmabadi
@CyrusNajmabadi
if where T : struct is there yes
if not, no. T? means (for unconstrained type parameters) "can be default"
if where T : class is tehre, def no.
note that that is already how NRT shipped for constrained generics
so the only discussion is about how to talk about unconstrained generics.
Jan Kučera
@miloush
yeah my scenario is unconstrained
if I remember correctly I couldn't resolve that without warning
so I am trying to figure out if that is yet to be shipped, or if warning is expected here
CyrusNajmabadi
@CyrusNajmabadi
feature is yhet to be shipped
it woudl be 9.0
Jan Kučera
@miloush
ok cool, thanks!
Jan Kučera
@miloush
sorry does that mean that there wouldn't be a way to have Nullable<T> for structs and nullable T for classes when unconstrained?
CyrusNajmabadi
@CyrusNajmabadi
that is correct
there is no such concept
never has been, likely will not be, absent some super compelling cases/customer asking for it
Jan Kučera
@miloush
understood!
Joseph Musser
@jnm2

sorry does that mean that there wouldn't be a way to have Nullable<T> for structs and nullable T for classes when unconstrained?

The .NET runtime itself would need to be deeply involved on this. For example, what metadata does this compile to?
class C<T> { public T? SomeField; }

Or class C<T1, T2> where T2 : IEnumerable<T1?> { }
Jan Kučera
@miloush
Sure, I was trying to verify I have correct understanding of the situation rather than suggesting this would be a useful/tenable feature.
Joseph Musser
@jnm2
Hopefully that helped to clarify. I would find the feature lovely, but it's a tough one.
Joseph Musser
@jnm2
Should this have a warning of some kind?
using var x = new SomethingDisposable();
{
    // Use x
}

// Do more stuff assuming x is gone
SivaSannidhi
@sivasannidhi
Hi I have scenario like creating multiple classes with different namespaces dynamically with help of Roslyn..i want to generate combine DLL with all of this outputs..what is the best way of create combine DLL..1.Create .Net Module as out put and combined as generic DLL 2.or Create .csProj with references and use MSBuildWorkSpace for combined DLL?
Yacoub Massad
@yacoubmassad_gitlab
Hello. I have a question regarding the MEF SharedAttribute. I noticed this attribute is applied to the Roslyn code fix provider class created by default in the provided template. Why is this attribute applied? Does it make the code fix provider a singleton?
CyrusNajmabadi
@CyrusNajmabadi
yes