Archive for the ‘C# 6 (Roslyn)’ Category
Posted by jpluimers on 2016/07/27
It comes down to these cases for XML elements having maxOccurs="1" (which the default for maxOccurs):
adding nillable="true" will convert from a regular type to a nullable type.
adding minOccurs="0" will add boolean …Specified properties in the generated C# for each element.
you can have both nillable="true" and minOccurs="0" in an element which gets you a nullable type and a …Specified property.
Note I’m not considering fixed or default here, nor attributes (that have use instead of minOccurs/maxOccurs, but do not allow for nillable ) nor larger values of maxOccurs (which both xsd.exe and xsd2code regard as unbounded).
From the above, XML has a richer type system than C#, so in XML there are subtle a differences between:
an explicit nil in the XML element
the XML element being absent
the XML element being empty.
Hopefully later more text and examples to show how to actually work with this.
Delphi related to minOccurs:
Note that xsd2code.codeplex.com (unlike XmlGen#) has at least two forks at github :
From the specs:
–jeroen
Posted in .NET , .NET 2.0 , .NET 3.0 , .NET 3.5 , .NET 4.0 , .NET 4.5 , C# , C# 2.0 , C# 3.0 , C# 4.0 , C# 5.0 , C# 6 (Roslyn) , Conference Topics , Conferences , Development , Event , Software Development , XML , XML/XSD , XSD | Leave a Comment »
Posted by jpluimers on 2016/07/07
Easy way to generate “System.InvalidOperationException: Nullable object must have a value.” .
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System;
public class Test
{
public static void Main()
{
int? nullableInt = null;
int nowInt = (int)nullableInt;
}
}
–jeroen
Posted in .NET , .NET 2.0 , .NET 3.0 , .NET 3.5 , .NET 4.0 , .NET 4.5 , C# , C# 2.0 , C# 3.0 , C# 4.0 , C# 5.0 , C# 6 (Roslyn) , Development , Software Development | Leave a Comment »
Posted by jpluimers on 2016/06/08
Boy I wish I had known this earlier. Like years ago…
In the Solution Explorer:
Right Click Project
Project Build Oder .
Use the dialog to change the build order
It is next to the “Project Dependencies” in this image from Sara Ford:
Sara Ford: change “Project Build Order”
In the resulting dialog, you can change the build order within your solution.
This can be very useful when – for various reasons – you cannot have Project Level dependencies for an assembly, but have to have Assembly Reference dependencies for individual assemblies.
At a client I bumped into this, and this dialog was a life saver for us.
Others have used it because some Visual Studio versions miscalculate the dependencies .
–jeroen
Did you know… How to change the build order for your solution? – #333 – Sara Ford’s Weblog – Site Home – MSDN Blogs .
Posted in .NET , C# , C# 2.0 , C# 3.0 , C# 4.0 , C# 5.0 , C# 6 (Roslyn) , Development , Software Development , Visual Studio 11 , Visual Studio 2008 , Visual Studio 2010 , Visual Studio 2012 , Visual Studio 2013 , Visual Studio and tools | Leave a Comment »
Posted by jpluimers on 2016/04/14
Visual Studio is a pretty big product and will take over 30GB of disk space after installation
Source: Visual Studio Frequently Asked Questions
LOL. It’s about half the size of recent Delphi versions.
–jeroen
Posted in .NET , .NET 4.0 , .NET 4.5 , C# , C# 5.0 , C# 6 (Roslyn) , Delphi , Delphi 10 Seattle , Delphi XE8 , Development , Software Development , VB.NET , Visual Studio 2015 , Visual Studio and tools , Xamarin Studio | 4 Comments »
Posted by jpluimers on 2016/03/22
Even though as of 12c R1, Oracle supports a row limiting clause , NHibernate 4.2 with Oracle.DataAccess.dll 2.112.3.0 does not support that.
When you let it generate the SQL for a LINQ Take call to limit the number of results , you get an exception like this (full exception and stack trace are below):
System.NotSupportedException was unhandled by user code
HResult=-2146233067
Message=Specified method is not supported.
The place where you Take is important, as this does fail:
Read the rest of this entry »
Posted in .NET , .NET 2.0 , .NET 3.0 , .NET 3.5 , .NET 4.0 , .NET 4.5 , .NET ORM , C# , C# 2.0 , C# 3.0 , C# 4.0 , C# 5.0 , C# 6 (Roslyn) , Database Development , Development , NHibernate , OracleDB , Software Development | Leave a Comment »
Posted by jpluimers on 2016/03/17
When you have one app.config for your whole set of DTAP environments (develop/test/acceptance production), every once in a while you get this error:
ORA-12154: TNS:could not resolve the connect identifier specified
For this particular setup, it means the replacement of parameters in the app.config with actual values from the DTAP went wrong (or was missing). For that we’ve some steps in both the PreBuildEvent and PostBuildEvent of the .csproj file:
PreBuildEvent :
del "$(ProjectDir)$(TargetFileName).config"
copy "$(ProjectDir)app.config" "$(ProjectDir)$(TargetFileName).config"
PostBuildEvent :
powershell -noprofile -file Replace-Parameter.ps1 -Path "$(TargetDir)$(TargetFileName).config"
The PreBuildEvent looks like it is not needed, but sometimes Visual Studio forgets to perform the copy action.
–jeroen
Posted in .NET , .NET 2.0 , .NET 3.0 , .NET 3.5 , .NET 4.0 , .NET 4.5 , .NET ORM , C# , C# 2.0 , C# 3.0 , C# 4.0 , C# 5.0 , C# 6 (Roslyn) , Database Development , Development , NHibernate , OracleDB , Software Development | Leave a Comment »
Posted by jpluimers on 2016/03/16
It seems I always forget about the InternalsVisibleTo attribute which allows you to specify which external assembly can see your internal types and type members:
Internal classes need to be tested and there is an assembly attribute:
using System.Runtime.CompilerServices;
[assembly:InternalsVisibleTo("MyTests")]
Add this to the project info file, e.g. Properties\AssemblyInfo.cs .
Thanks Eric Schaefer for that answer .
–jeroen
via .net – C# “internal” access modifier when doing unit testing – Stack Overflow .
Posted in .NET , .NET 2.0 , .NET 3.0 , .NET 3.5 , .NET 4.0 , .NET 4.5 , C# , C# 2.0 , C# 3.0 , C# 4.0 , C# 5.0 , C# 6 (Roslyn) , Development , Software Development | Leave a Comment »
Posted by jpluimers on 2016/02/16
When you own the full stack:
virtual machine (Build 201602)
These installs contain:
Windows 10 Enterprise Evaluation, Version 1511
Visual Studio 2015 Community Update 1
Windows developer SDK and tools (Build 10586)
Windows IoT Core SDK and Raspberry Pi 2 (Build 10586.0.151029-1700)
Windows IoT Core project templates (Version 1.0)
Microsoft Azure SDK for .NET (Build 2.8.2)
Windows Bridge for iOS (Build 0.1.0.160114)
Windows UWP samples (Build 2.0.4)Windows Bridge for iOS samples
The VMware VM link redirects to https://windowsdeveloper.azureedge.net/vm-1602/Win10Eval_1602_VMware.zip
Also available for Hyper-V , VirtualBox , Parallels
–jeroen
Source: Get a Windows 10 development environment – Windows app development
Posted in .NET , .NET 4.5 , C# , C# 5.0 , C# 6 (Roslyn) , Cloud Development , Development , Hardware Development , Raspberry Pi , Software Development , VB.NET , VB.NET 14.0 , Visual Studio 2015 , Visual Studio and tools , Windows Azure | Leave a Comment »
Posted by jpluimers on 2016/02/16
This was very useful to get a WebClient with a WebProxy configured to use a proxy server that is based on NTLM authentication.
The note in the MSDN NTLM and Kerberos Authentication . documentation however was totally wrong.
String MyURI = "http://www.contoso.com/";
WebRequest WReq = WebRequest.Create MyURI;
WReq.Credentials = CredentialCache.DefaultCredentials;
Note NTLM authentication does not work through a proxy server.
This code works perfectly fine as the CredentialsCache.DefaultCredentials contains your NTLM or Kerberos credentials .
It even works when you have a local Fiddler http proxy as a facade in front of your NTLM proxy.
Read the rest of this entry »
Posted in .NET , .NET 2.0 , .NET 3.0 , .NET 3.5 , .NET 4.0 , .NET 4.5 , C# , C# 2.0 , C# 3.0 , C# 4.0 , C# 5.0 , C# 6 (Roslyn) , Development , Fiddler , Software Development , Web Development | Leave a Comment »
Posted by jpluimers on 2016/01/27
You’d think this is a simple question.
Be amazed by the many ways leading into to creating a temporary file with a specific extension.
This list doesn’t even cover all of them:
Create a file name based on GetTempPath, a Guid and an extension.
Use the TempFileCollection from the Compiler in System.CodeDom.
Get a random file name, then change the extension. Loop until it is unique.
Use a timestamp to generate unique file names.
All via: c# – How can I create a temp file with a specific extension with .net? – Stack Overflow .
Which one would you choose?
–jeroen
Posted in .NET , .NET 1.x , .NET 2.0 , .NET 3.0 , .NET 3.5 , .NET 4.0 , .NET 4.5 , C# , C# 1.0 , C# 2.0 , C# 3.0 , C# 4.0 , C# 5.0 , C# 6 (Roslyn) , Development , RemObjects C# , Software Development | Leave a Comment »