Skip to content

Commit f0426f7

Browse files
ClémentClément
authored andcommitted
Working on v10 of projects, restoring missing PropertySafety project.
1 parent b2742aa commit f0426f7

3 files changed

Lines changed: 52 additions & 1 deletion

File tree

source/Makefile

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,11 +538,19 @@ tidy:
538538
$(BUILD_DIR)$(PROJECT_DIR)%.zip: $(PROJECT_DIR)%.zip
539539
@mkdir -p $(dir $@)
540540
@rsync -av $(subst $(BUILD_DIR),,$@) $@
541+
542+
$(PROJECT_DIR)%.zip: $(PROJECT_DIR)%/*/Program.cs | $(PROJECT_DIR)/%/*/*.cs
543+
@(printf '<Project Sdk="Microsoft.NET.Sdk">\n <PropertyGroup>\n <OutputType>Exe</OutputType>\n <TargetFramework>net10.0</TargetFramework>\n <ImplicitUsings>enable</ImplicitUsings>\n <Nullable>enable</Nullable>\n </PropertyGroup>\n \n</Project>') > $(dir $<)$(notdir $(patsubst %/,%,$(dir $<))).csproj
544+
# We now zip the folder:
545+
@cd $(dir $(patsubst %/,%,$(dir $<))) && 7z a $(notdir $@) $(notdir $*) -xr\!.vs -xr\!.directory > nul && mv $(notdir $@) ../
546+
# We compress (silently, thanks to the -bso0 -bsp0 options) the folder containing the csproj and the code
547+
# Finally, we clean the files:
548+
@rm $(dir $<)$(notdir $(patsubst %/,%,$(dir $<))).csproj
541549

542550
# Rule to create one individual project and zip it:
543551
# The code below is taken from and documented at
544552
# https://github.com/princomp/C-Sharp-project-maker
545-
$(PROJECT_DIR)%.zip: $(PROJECT_DIR)%/*/Program.cs | $(PROJECT_DIR)/%/*/*.cs
553+
$(PROJECT_DIR)%_v4.5.2.zip: $(PROJECT_DIR)%/*/Program.cs | $(PROJECT_DIR)/%/*/*.cs
546554
#
547555
# The structure of an archive is as follows:
548556
# └───<Solution> $(notdir $*)
@@ -601,6 +609,11 @@ $(PROJECT_DIR)%.zip: $(PROJECT_DIR)%/*/Program.cs | $(PROJECT_DIR)/%/*/*.cs
601609
@cd $(dir $(patsubst %/,%,$(dir $<)))../ && 7z a $(notdir $@) $(notdir $*) -xr\!.vs -xr\!.directory > nul
602610
# We compress the folder containing the sln and the folder containing the csproj and the code
603611
# But we exclude the .vs folder and .directory file
612+
# Finally, we clean the files:
613+
@rm -rf $(dir $(patsubst %/,%,$(dir $<)))/$(notdir $*).sln
614+
@rm -rf $(dir $<)$(notdir $(patsubst %/,%,$(dir $<))).csproj
615+
@rm -rf $(dir $<)Properties
616+
@rm -rf $(dir $<)Properties/AssemblyInfo.cs
604617

605618
# -------------------------------
606619
# Book files
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
3+
class Program
4+
{
5+
static void Main()
6+
{
7+
PropertySafety test = new PropertySafety();
8+
9+
try
10+
{
11+
test.SensibleData = "Forbidden word";
12+
}
13+
catch (AccessViolationException ex)
14+
{
15+
Console.WriteLine(ex.Message);
16+
}
17+
Console.WriteLine(test.SensibleData);
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
3+
class PropertySafety
4+
{
5+
private string sensibleData;
6+
public string SensibleData
7+
{
8+
set
9+
{
10+
if (value == "Forbidden word")
11+
{
12+
Console.WriteLine("Intrusion detected, aborting!");
13+
throw new AccessViolationException();
14+
}
15+
sensibleData = value;
16+
}
17+
get { return sensibleData; }
18+
}
19+
}

0 commit comments

Comments
 (0)