venerdì, febbraio 25, 2011

ILSpy

Dalla fine di Febbraio 2011 Reflector non sarà più un prodotto gratuito. Due alternative: 35$ per la versione a pagamento oppure ILSpy.
ILSpy è disassemblatore come Reflector, è open-source ed è gratuito. Sviluppato dalle stesse persone di SharpDevelop.  L'ho provato e sembra funzionare molto bene. :)




[Update:  al momento non supporta LINQ. Forse in futuro... http://wiki.sharpdevelop.net/SharpZipLib_Roadmap.ashx]

mercoledì, febbraio 09, 2011

Piccolo contributo ad un libreria di Google

Vabbè, lo so è proprio una cosa da poco, sono solo 10 righe di codice o poco più, ma comunque la cosa mi fa proprio piacere.  Un grazie a Claudio.
http://code.google.com/p/google-gdata/issues/detail?id=477

domenica, febbraio 06, 2011

How to transform a pure Class Library project into a WCF Service Library

WCF Service Library projects are classic Class Library projects plus some very useful features:
  • they auto-host themselves using the utility WCF Service Host
  • they can be called and tested using the utility WCF Test Client
  • they can be discovered and added in other projects of the same solution using "Add Service Reference..."

(WCF Service Host and WCF Test Client are part of Visual Studio 2010).

The differences between the two type of project are in the .csprojct file. So, you can transform a classis Class Library project inot a WCF Service Library project modifying the .csproj file.

Steps:

* close VS2010
* do a complete backup of the whole solution   :)
* edit the "Class Library" .csproj using notepad (or other text editor)
* under <PropertyGroup> add:
    <ProjectTypeGuids>{3D9AD99F-2412-4246-B90B-4EAA41C64699};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    <StartArguments>/client:"WcfTestClient.exe"</StartArguments>


    * after <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> add:

    <ProjectExtensions>
    <VisualStudio>
    <FlavorProperties GUID="{3D9AD99F-2412-4246-B90B-4EAA41C64699}">
    <WcfProjectProperties>
    <AutoStart>True</AutoStart>
    </WcfProjectProperties>
    </FlavorProperties>
    </VisualStudio>
    </ProjectExtensions>



    The resulting file should looks like this:

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>8.0.30703</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{08536F3E-152A-46C0-8C63-C0821FE5DE7C}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>PureClassLib</RootNamespace>
    <AssemblyName>PureClassLib</AssemblyName>
    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <ProjectTypeGuids>{3D9AD99F-2412-4246-B90B-4EAA41C64699};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    <StartArguments>/client:"WcfTestClient.exe"</StartArguments>

    </PropertyGroup>
    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    </PropertyGroup>
    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    </PropertyGroup>
    <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Core" />
    <Reference Include="System.Runtime.Serialization" />
    <Reference Include="System.ServiceModel" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Xml" />
    </ItemGroup>
    <ItemGroup>
    <Compile Include="AcmeService.cs" />
    <Compile Include="Class1.cs" />
    <Compile Include="IAcmeService.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
    </ItemGroup>
    <ItemGroup>
    <None Include="app.config" />
    </ItemGroup>
    <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    <ProjectExtensions>
    <VisualStudio>
    <FlavorProperties GUID="{3D9AD99F-2412-4246-B90B-4EAA41C64699}">
    <WcfProjectProperties>
    <AutoStart>True</AutoStart>
    </WcfProjectProperties>
    </FlavorProperties>
    </VisualStudio>
    </ProjectExtensions>

    <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
    Other similar extension points exist, see Microsoft.Common.targets.
    <Target Name="BeforeBuild">
    </Target>
    <Target Name="AfterBuild">
    </Target>
    -->
    </Project>




    A useful link to understand Project Types:  http://www.mztools.com/Articles/2008/MZ2008017.aspx



    Connet an Android app to Google App Engine - Authenticated !

    Sometime ago I read a very interesting post on Nick'blog: "Authenticating against App Engine from an Android app"  http://blog.notdot.net/2010/05/Authenticating-against-App-Engine-from-an-Android-app
    The code was very intersting but I need to refactor a bit and I'd like to add some "utility" method.
    Also I added a way to automatically invalidate old Auth token and get a new one.

    My code (very alpha... I'm still working on it...) is here:
    http://code.google.com/p/fhpublicstuff/source/browse/test/GAEConnector/GAEConnector.java

    [Update: it manages http and https connections to GAE]

    Usage:


    // ....
    _gaeConnector = new GAEConnector(null, "http://AAAAAAAA.appspot.com");
    if (!_gaeConnector.Authenticate(MyTest.this)) {
      message = "***AUTHENTICATION ERROR***";
    }
    // .....
    if (_gaeConnector.isAuthenticated()) {
      int httpStatusCode = _gaeConnector.GETContent("/myurl", true, true);
      if (httpStatusCode == 200) {
        String content = _gaeConnector.getLastContent();
        // ....